On Thu, Sep 3, 2009 at 8:41 PM, bill lam<[email protected]> wrote:
>
> This is supposed to remove trailing spaces using autocmd
>
> autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
>
> However if I changed it into
>
> autocmd BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
>
> adding some trailing spaces and then :w or :x
> it appeared that those trailing spaces are still there. Any idea
> what's going wrong?
I can't spot any mistake, but then I haven't tried it myself. I
recommend creating a function such that you can put a breakpoint and
see what is going on. Also try removing silent and the "e" flag such
that vim can print any errors, in case the substitute is failing
(though again, I can't spot any mistake).
autocmd BufWrite * call T()
function! T()
if ! &bin
%s/\s\+$//g
endif
endfunction
PS: Here is a plug for my breakpts plugin to make it easier to put a
breakpoint. Once you install breakpts.vim, change the function like
this to stop Vim at the first line:
function! T()
exec BPBreak(1)
if ! &bin
%s/\s\+$//g
endif
endfunction
Download breakpts.vim from here: http://www.vim.org/script.php?script_id=618
--
HTH,
Hari
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---