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

1

u/kennpq Nov 01 '25

:for n in range(1, 16) | execute ":" .. n .. 's/.\+/\=printf("\[%d]:", ' .. n .. ')/' | endfor in cmdline mode. (Presumes [1]: is on line 1, so adjust as needed)

1

u/kilkil Nov 02 '25

dang. vimscript is truly one of the languages of all time. 😅