Make Vim show ALL white spaces as a character
I can't find a way to make Vim show all white spaces as a character. All I found was about tabs, trailing spaces etc.
As others have said, you could use
:set list
which will, in combination with
:set listchars=...
display invisible characters.
Now, there isn't an explicit option which you can use to show whitespace, but in listchars, you could set a character to show for everything BUT whitespace. For example, mine looks like this
:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
so, now, after you use
:set list
everything that isn't explicitly shown as something else, is then, really, a plain old whitespace.
As usual, to understand how listchars
works, use the help. It provides great information about what chars can be displayed (like trailing space, for instance) and how to do it:
:help listchars
It might be helpful to add a toggle to it so you can see the changes mid editing easily (source: VIM :set list! as a toggle in .vimrc):
noremap <F5> :set list!<CR>
inoremap <F5> <C-o>:set list!<CR>
cnoremap <F5> <C-c>:set list!<CR>
:set list
to enable.
:set nolist
to disable.
As of patch 7.4.710 you can now set a character to show in place of space using listchars!
:set listchars+=space:␣
So, to show ALL white space characters as a character you can do the following:
:set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣
:set list
Discussion on mailing list: https://groups.google.com/forum/?fromgroups#!topic/vim_dev/pjmW6wOZW_Q
链接地址: http://www.djcxy.com/p/28640.html上一篇: 将选项卡重新定义为4个空格
下一篇: 让Vim将所有空格显示为一个字符