Skip to content

Instantly share code, notes, and snippets.

@gwintrob
Last active December 10, 2015 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwintrob/4440044 to your computer and use it in GitHub Desktop.
Save gwintrob/4440044 to your computer and use it in GitHub Desktop.
Strip trailing whitespace in Vim
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd FileType c,cpp,java,php,ruby,python autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment