Skip to content

Instantly share code, notes, and snippets.

@bronson
Created September 15, 2010 20:24
Show Gist options
  • Save bronson/581417 to your computer and use it in GitHub Desktop.
Save bronson/581417 to your computer and use it in GitHub Desktop.
My attempt (bad):
function s:FixWhitespace() range
for lineno in range(a:firstline, a:lastline)
call setline(lineno, substitute(getline(lineno), '\s\+$', '', ''))
endfor
endfunction
" Run :FixWhitespace to remove end of line white space.
command! -range=% FixWhitespace silent! <line1>,<line2>call <SID>FixWhitespace
Original command (works):
command! -range=% FixWhitespace silent! let savesearch = @/ | keepjumps <line1>,<line2>substitute/\s\+$// | let @/ = savesearch | unlet savesearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment