Today I Learned

A Hashrocket project

Auto remove trailing whitespace

Copy this in your .vimrc.local, and any trailing whitespace will be highlighted, and automatically removed when you write the file.

"highlight trailing whitespace
match ErrorMsg '\s\+$'
" kill trailing whitespaces automatically
autocmd BufWritePre * :%s/\s\+$//e

Yes, I totally stole this from someone else’s vimrc on github. https://github.com/rwz/dotfiles/blob/master/vim/vimrc

Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the monthly Vim Chicago Meetup hosted at our Chicago office.