Hello all,

I have been using the following hack to remove trailing whitespace:

autocmd BufWritePre,FileWritePre * call StripTrailingWhitespace()
function! StripTrailingWhitespace()
    normal mz
    normal Hmy
    exec '%s/\s*$//g'
    normal 'yz<cr>
    normal `z
endfunction

However, that has several negative side-effects - e.g. messing with
the undo stack and sometimes altering the cursor position.

I have read through various discussions and guides*, but haven't found
a better solution so far.
This seems like a common issue (even though some might argue doing
this automatically is wrong), so I was wondering whether there was a
canonical solution I might have missed?

Any tips would be greatly appreciated!


-- F.


* e.g. http://vim.wikia.com/wiki/Remove_unwanted_spaces

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to