Skip to content

Instantly share code, notes, and snippets.

@eupharis
Created July 31, 2013 17:36
Show Gist options
  • Save eupharis/6124245 to your computer and use it in GitHub Desktop.
Save eupharis/6124245 to your computer and use it in GitHub Desktop.
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre * :call TrimWhiteSpace()
function TrimEndLines()
let save_cursor = getpos(".")
:silent! %s#\($\n\s*\)\+\%$##
call setpos('.', save_cursor)
endfunction
autocmd BufWritePre * :call TrimEndLines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment