Trailing Whitespace, No More!

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.

The Basics

After installation using your favorite plugin manager, try the following

  • Toggle whitespace highlighting on/off: :ToggleWhitespace
  • Clean extra whitespace: :StripWhitespace
  • To enable stripping of extra whitespace on file save add this line[1] to your .vimrc:
autocmd BufEnter * if index(g:better_whitespace_filetypes_blacklist, &ft) < 0 | exec 'EnableStripWhitespaceOnSave' | endif

[1] 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.

trailing whitespace is bad mkay

Learn more and contribute at GitHub or

comments powered by Disqus