Reply to message «Help w/ AutoCmd Error Message», 
sent 22:45:43 05 May 2011, Thursday
by Gary Furash:

> 2. This seems to WORK fine, but when they're aren't any trailing
> characters, it prints out an error message. I just want it to do its thing
> and not tell me if there aren't any trailing characters to fix.
There are three ways of doing this:
1. General: use :silent! command:
    :silent! %s/\s\+$//g
2. General: use :try .. catch:
       :execute "try\n%s/\\s\\+$//g\ncatch /^Vim(substitute):E486:/\nendtry"
   (:execute is not required, but `try | ... | catch | endtry' may produce
   strange results).
3. :substitute-specific /e flag:
    :%s/\s\+$//ge

Original message:
> I checked the AutoCmd documentation and did not find a "silent" statement.
> 
> 1. I've added the following commands to my VIMRC for the purposes of
> assuring (a) that documentation is always setup and (b) there aren't any
> trailing characters
> 
> autocmd BufWritePre * :%s/\s\+$//g
> autocmd BufWritePre * :%s/^$\n^$//g
> autocmd VimEnter    * :helptags ~/.vim/doc
> 
> 2. This seems to WORK fine, but when they're aren't any trailing
> characters, it prints out an error message. I just want it to do its thing
> and not tell me if there aren't any trailing characters to fix.
> 
> Is there a way to silence the execution of these commands? Thanks.
> 
> 
> Gary Furash| [email protected] | 520-907-2470 | @CrabGary (twitter) |
> http://gfurash.blogspot.com

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to