François Ingelrest wrote the following on 11.03.2007 15:39:
> Hi,
> 
> As the title says, I want to automatically remove trailing spaces when
> I save a file. This is what I put in my vimrc:
> 
> au BufWrite * %s/\s\+$//ge
> 
> This works correctly only when at least one match is found, an error
> is issued if I want to save a file without trailing spaces. However,
> using the 'e' flag for the substitute command should discard any such
> error (at least it's working when I use this command interactively).
> Did I miss something?

I had the same issue with that (error message on not finding matches)
this is what i use now:

" automatically delete trailing Dos-returns,whitespace
autocmd BufRead,BufWritePre,FileWritePre * silent! %s/[\r \t]\+$//
                                           ^^^^^^

HTH Thilo
-- 
i am on Ubuntu 2.6 KDE
- some friend of mine

gpg key: 0x4A411E09

Reply via email to