Differences

This shows you the differences between two versions of the page.

Link to this comparison view

incnum [2014/10/26 01:52] (current)
Line 1: Line 1:
 +==== Incremental numbering within vim ====
  
 +Increment heading numbers within a line range.
 +
 +
 +Here's how it works:
 +
 +If you have
 +
 +1. Foo
 +2. Bar
 +3. Baz
 +4. Whee
 +5. Zonk!
 +
 +and add "2. Foo-1",​ you'll get
 +
 +1. Foo
 +2. Foo-1
 +2. Bar
 +3. Baz
 +4. Whee
 +5. Zonk!
 +
 +Now, if you want to fix the numbering, go to "2. Bar", mark the location
 +with '​ma',​ then go to "5. Zonk!",​ mark it '​mb'​.
 +
 +Then, use the '​exe'​ command with '​norm'​ to match lines starting with numbers
 +(within the defined range) and increment their numbers:
 +
 +:'​a,'​b g/^\d\+/exe "norm! \<​c-a>"​
 +
 +(Using the old CTRL-A trick to increment the number the cursor'​s on).
 +----
 +  * [[vim|Back to Vim tips]]
incnum.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0