138482Re: find and replace with sequential numbers
- Jul 12, 2013On 2013-07-12 19:05, Paul Isambert wrote:
> Chris Lott <chris@...> a écrit:I'm pretty sure it requires a counter, but it can be done with
> > I have a document with the following kind of text:
> > ## 3. foo
> > various text here
> > ## 1. foo
> > more text here
> > What I would like to do is search for all the headers (## X. etc)
> > and replace them with the proper sequential numbering. How do I
> > approach this?
> I’m sure some “vizard” can do the same without using a counter like
> a:count (and, of course, with :substitute).
a :substitute command and a helper function:
let b:counter += 1
:let b:counter=0 | %s/## \zs\d\+\ze\./\=Add()
This also give you pretty easy access to change the starting index,
and if you wanted to pass an increment-amount to Add(), it could be
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@....
For more options, visit https://groups.google.com/groups/opt_out.
- << Previous post in topic Next post in topic >>