I found a really neat way of incrementing a number in text in vim. It works perfectly fine but only if I yank one line. If there is a whole paragraph in which I want to increment one number it does not work. Here is how it works on single line:
qa
Y
p
Ctrl-A
q
and then type 15@a to perform the macro 15 times.
Does anyone know how to apply the same logic to something like this:
text 1
bla bla 1
So what I want is:
text 2
bla bla 2
text 3
bla bla 3
... and so on
One way is to record the following macro:
qayipjo<Esc>pvip<C-a>q
Breakdown:
qa start recording
yip yank inner paragraph
jo<Esc> insert line after paragraph
p paste
vip select inner paragraph
<C-a> increment all numbers
q stop recording
This macro may be repeated via 15@a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With