Tip 94: Perform Arithmetic on the Replacement
Return to the top: <<Practical Vim>>
Example: promote each heading
<h2>Heading number 1</h2> <h3>Number 2 heading</h3> <h4>Another heading</h4>
The Search Pattern
/\v\<\/?h\zs\d
NOTE: \zs
excludes the "h" itself.
The Substitute Command
:%s//\=submatch(0)-1/g