Showing trailing spaces in vim

To highlight trailing whitespace characters:

:set hlsearch, then

/\s\+$


You should check this link. I'm using the match command solution :

:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+$/

This page also provides list based solutions which I haven't personally tried.


And expected to see dots in those places where spaces are used for tabulation in the code (I use spaces, not tabs)

Actually this is the other way round, tab option is used to display a character when a tab character is inserted (\t) instead of spaces. And trail is use to show trailing spaces at the end of lines.

You seem to have single empty line with trailing spaces, and dots are correctly displayed.

If you are only using spaces tab option is not used or displayed.


The vim-better-whitespace plugin incorporates many tips from the Vim Wiki page referenced in @icecrime's answer. It also has some nifty configuration options.

I installed pathogen.vim just to use this plugin and am happy with my life, all things considered.