Vim is awesome and it can remove all trailing whitespace automatically.
For the Current File:
# on every file save
autocmd BufWritePre * :%s/\s\+$//e
# on certain file extension
autocmd BufWritePre *.rb :%s/\s\+$//e
# on certain file types
autocmd FileType ruby,php,java autocmd BufWritePre <buffer> :%s/\s\+$//e
Related External Links: