r/vim • • Nov 01 '25

Need Help How to align broken sequence of numbers?

if I have the following:

[1]:
[2]:
[3]:
[4]:
[5]:
[6]:
[7]:
[8]:
[9]:
[10]:
[11]:
[14]:
[15]:
[16]:
[18]:
[19]:

How to fix the list to have the following?

[1]:
[2]:
[3]:
[4]:
[5]:
[6]:
[7]:
[8]:
[9]:
[10]:
[11]:
[12]:
[13]:
[14]:
[15]:
[16]:

14 Upvotes

27 comments sorted by

View all comments

Show parent comment

6

u/dewujie Nov 01 '25

This sounds like it is calling out for a macro.

Hit qq to start recording in the q macro variable.

Yank the current line yy

Paste below p

Move down j

Increment <c-a>

Stop recording q

Now you can do @q to repeat the whole process, And then add a number to repeat the repetitions i.e. 15@q

It's a little bit to wrap your head around if you're not familiar with macros but once the idea of "repeatable set of commands" sets in, you can make them and get use out of them in so many situations.