On Mon, Oct 7, 2013 at 5:42 PM, Ben Fritz <[email protected]> wrote:

> On Monday, October 7, 2013 8:00:38 AM UTC-5, Yosi Izaq wrote:
> > Hi,
> >
> > I want to selectively increment numbers in substitute.
> > I'm familiar w/ submatch for increment all numbers in substitute, like
> in vis. mode range:
> > '<,'>s/\d\+/\=submatch(0)+1/gc
> >
> > But what if I want to increment numbers only of lines containing a
> preceding pattern, say "Number".
> > For instance:
> > "
> > 1
> > Number: 2
> > "
> >
> > Should change to:
> > "
> > 1
> > Number: 3
> > "
> >
> > TIA,
> > Thanks!
> > Yosi
>
> This is a perfect use for the :g command, for example using your
> substitute:
>
> :'<,'>g#^Number#s/\d\+/\=submatch(0)+1/gc
>
>
Works like a charm. Thank you!

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to