Nobody likes trailing whitespace. I usually notice them only when looking at my committed changes.
Stripping extra white space always seemed like something I shouldn’t worry about.
Today I learned about a cool vim plugin called vim-better-whitespace, by ntpeters.
After installation using your favorite plugin manager, try the following
- Toggle whitespace highlighting on/off:
- Clean extra whitespace:
- To enable stripping of extra whitespace on file save add this line to your
autocmd BufEnter * if index(g:better_whitespace_filetypes_blacklist, &ft) < 0 | exec 'EnableStripWhitespaceOnSave' | endif
 There’s an open issue regarding the use of blacklist file types when enabling whitespace stripping on file save. The line I wrote above is the author’s suggested fix.
Learn more and contribute at GitHub or Vim.org.