Skip to content

Instantly share code, notes, and snippets.

@spadin
Last active December 6, 2018 21: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 spadin/7216061 to your computer and use it in GitHub Desktop.
Save spadin/7216061 to your computer and use it in GitHub Desktop.
Simple function for striping trailing whitespace in Vim.
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
map <Leader>cw :call <SID>StripTrailingWhitespaces()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment