Show whitespace characters in gvim

前端 未结 4 1743
孤街浪徒
孤街浪徒 2020-12-23 10:05

Is there an easy way to display whitespace characters such as space and tab in gvim? Something like what is implemented in Gedit, Geany, Komodo, and other GUI editors where

相关标签:
4条回答
  • 2020-12-23 10:22

    This works well for me:

    "trailing white space detection
    highlight WhitespaceEOL ctermbg=yellow guibg=yellow
    match WhitespaceEOL /\s\+$/
    
    0 讨论(0)
  • 2020-12-23 10:28

    Here are some of my settings pertaining whitespace.

    Use F11 to toggle between displaying whitespace characters or not:

    noremap <F11> :set list!<CR>
    

    How to show whitespace characters when list is set:

    set listchars=eol:$,tab:>-,trail:.,extends:>,precedes:<,nbsp:_
    

    Highlight special characters in yellow:

    highlight SpecialKey term=standout ctermbg=yellow guibg=yellow
    

    Highlight redundant spaces (spaces at the end of the line, spaces before or after tabs):

    highlight RedundantSpaces term=standout ctermbg=Grey guibg=#ffddcc    
    call matchadd('RedundantSpaces', '\(\s\+$\| \+\ze\t\|\t\zs \+\)\(\%#\)\@!')
    

    Hope these help!

    0 讨论(0)
  • 2020-12-23 10:33

    Check out listchars and list options in Vim. An example use of this feature:

    " part of ~/.vimrc
    " highlight tabs and trailing spaces
    set listchars=tab:>-,trail:-
    set list
    
    0 讨论(0)
  • 2020-12-23 10:35

    You can use any characters you wish if you enable Unicode first

    set encoding=utf-8
    

    One line I use (put in ~/.vimrc):

    set list listchars=tab:→\ ,trail:·
    

    Learn more about this setting at http://vim.wikia.com/wiki/Highlight_unwanted_spaces

    The color of these characters is controlled by your color scheme.

    0 讨论(0)
提交回复
热议问题