Guys... thanks for the suggestions...

Tim your suggestion is working great... can't believe I didn't think
of that.

Tony... I tried using the submatch but it doesn't look like the
submatch function is supported in our vim installation.  Also hadn't
thought of a try catch finally... something to keep in mind for future
stuff.

On Dec 16, 3:20 pm, Tony Mechelynck <[email protected]>
wrote:
> On 16/12/08 20:12, BigAl wrote:
>
> > How can I break out of a series of commandline commands from within
> > the commandline?
>
> > Here is my command line, it finds the text "XXXX" and replaces that
> > text with an incremented number (variable i) up to the max replacement
> > value of 3999.
> > :let i=1120|%g/XXXX/s/\zsXXXX\ze/\=i/|let i=i+1|if (i>  3999)|break|
> > endif
>
> > Everything works great except for the "break" statement.  When the
> > "break" is hit it generates an error since break is only intended for
> > use with a while statement.  I've tried putting the "<Esc>" text in
> > place of the break statement, I've tried inserting a ctrl-c in line...
> > and I can't make any of them work.
>
> Here's another attempt (untested)
>
>      :let i = 1120 | %g/XXXX/s/XXXX/\=(i<4000?i:submatch(0)) | let i += 1
>
> Alternately, you might put a try/endtry block around the argument of the
> ":g" statement to catch the generated error, see
>         :help :try
>         :help :catch
>         :help :finally
>
> Best regards,
> Tony.
> --
> "Star Wars is adolescent nonsense; Close Encounters is obscurantist
> drivel; Star Trek can turn your brains to purée of bat guano; and the
> greatest science fiction series of all time is Doctor Who!  And I'll
> take you all on, one-by-one or all in a bunch to back it up!"
>                 -- Harlan Ellison
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to