How to Display Hidden Characters in vim?

You can use the commands

:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
:set list

to show all characters that aren't whitespace. So spaces are the only thing that doesn't show up.

If you absolutely need spaces to be marked as well, you'll need to try something less nice. Something like

:%s/ /█/g

Will replace all spaces with a block character. Then you'd need to undo it before writing. You could remap your write command do

cmap :w :%s/█/ /g<CR>:w

Just a suggestion. I haven't tried that though.


More recent versions of vim can show spaces as well. (Confirmed on vim 7.4.1689).

:set list
:set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»