Vim augroup DeleteTrailingWhitespaces autocmd! autocmd BufWritePre * ks|execute "%s/\\s\\+$//ge"|'s augroup END Emacs