Thanks  to both of you! I now use this command and it's working perfectly:

au BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif

On 3/11/07, Thilo Six <[EMAIL PROTECTED]> wrote:
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]\+$//
                                           ^^^^^^

Reply via email to