On Fri, Jul 12, 2013 at 12:21 PM, Chris Lott <[email protected]> wrote: > 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? > > c > -- > Chris Lott <[email protected]> > > -- > -- > 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.
The following should do it: :let i = 1 :g/## \d\+\./ s/\d\+/\=i/ | let i = i + 1 The relevant helptags are |:g| and |sub-replace-expression|. There's also the Nexus plugin: <http://of-vim-and-vigor.blogspot.com/2012/04/do-it-with-vim-nexus.html> --Adnan -- -- 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.
