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 (when the option is turned on) spaces show as a muted or greyed-out '.' and tabs as '-->'.
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
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.
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!
This works well for me:
"trailing white space detection
highlight WhitespaceEOL ctermbg=yellow guibg=yellow
match WhitespaceEOL /\s\+$/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.