Tim Chase wrote:

> On 03/18/2011 11:27 AM, Bram Moolenaar wrote:
> > Tim Chase wrote:
> >>     :try | /does_not_exist/ | catch /.*/ | endtry
> >>
> >> """
> >> Error detected while processing :
> >> E486: Pattern not found: does_not_exist
> >> """
> >
> > You need to put the "catch" on a separate line, because when skipping
> > commands it will skip the line(s) after where the error happened.  That's
> > because when there is an error finding the " | " is unreliable.
> 
> Hmmm...peculiar given the help example from ":help :throw"
> 
>     :try | throw "oops" | catch /^oo/ | echo "caught" | endtry
> 
> suggests that an exception being thrown can be caught by a :catch 
> in the same line.
> 
> My assumption that a single line-destination (whether line-number 
> or search) would be treated as a command seems consistent with 
> the scattered documentation I've found on it (emphasis on them 
> being called "*commands*" is mine):
> 
> cmdline.txt|554 col 1| :3                     goto line 3
>    referred to as "strange *commands*"
> 
> options.txt|1969 col 23| CTRL-N, CTRL-J and ":1234".
>    "Applies to the *commands*"
> 
> options.txt|6232 col 32| only has a line number, e.g., ":25" or ":+".
>    "Also for an Ex *command* that only has a line number"
> 
> 
> While I consider this a bug, at a minimum, the gotcha regarding 
> catch being on its own line doesn't seem to be readily documented 
> in the section on :try and :catch

The problem is with each individual command, how it detects where the
command ends.  Sometimes it finds the "|" before the error is thrown,
then it is OK.  When using a regexp it's not so easy to find the "|" and
it may skip the whole rest of the line.

I'll add a comment at the :throw example that it doesn't always work
like this.

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to