2012-01-03 04:27:36 +08:00
|
|
|
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
|
|
|
|
" Strip trailing whitespace
|
|
|
|
function! <SID>StripTrailingWhitespaces()
|
|
|
|
" Preparation: save last search, and cursor position.
|
|
|
|
let _s=@/
|
|
|
|
let l = line(".")
|
|
|
|
let c = col(".")
|
|
|
|
" Do the business:
|
|
|
|
%s/\s\+$//e
|
|
|
|
" Clean up: restore previous search history, and cursor position
|
|
|
|
let @/=_s
|
|
|
|
call cursor(l, c)
|
|
|
|
endfunction
|
|
|
|
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
|
2012-01-07 02:31:24 +08:00
|
|
|
nmap ,w :StripTrailingWhitespaces<CR>
|