Wednesday, October 23, 2013

Re: selective increment numbers in substitute

Hi,

You can also write a macro:

qq/Number<CR><c-a>q

which might be quicker to type, but then you have to know how many times
to call it. So here is another approach with a :g command:

:g/Number/normal<c-v><c-a>

Both solutions are assuming you don't have alpha in nrformats option.

Best,
Marcin

On 09:35 Wed 23 Oct , BimbaLaszlo wrote:
> 2013. október 7., hétfő 15:00:38 UTC+2 időpontban Yosi Izaq a következőt írta:
> > 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
>
> You can use the NumUtils plugin for it: http://www.vim.org/scripts/script.php?script_id=4634
> The command should looks like this:
>
> :NumUtilsAdd 1, 'Number: '
>
> --
> --
> 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 vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: