less is more.
Extra trailing spaces are junk that clobber files.
So here is what I've added to my .vimrc:
Extra trailing spaces are junk that clobber files.
- It takes room for nothing
- It can cause unwanted diff when you add or remove them, though there are not significant
- It's annoying moving around with the carret...
So here is what I've added to my .vimrc:
" hilight withspaces
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+\%#\@
The last line is my own addition to what I've found on wikia
But remember: don't check in significant changes along with unsignificant changes, otherwise it confuses people looking at history and staring at your commit. One change should just be formatting and the changelog should advertise that, and the other should be the real significant change.
update: I've found a better way to remove spaces:
nnoremap,ew :let _s=@/ :%s=\s\+$==e :let @/=_s :nohl
This has the nice benefit of recovering the previous search you were doing, otherwise if you press 'n', then you would only search for the next trailing space in the file.