Vim autocmd BufWritePre * :%s/\s\+$//e Emacs (add-hook 'before-save-hook 'delete-trailing-whitespace) Textmate