# Tag Info

### How to copy each line 11 times, incrementing the last "1" in each line from 2-12

You could do this by recording a macro, then using the global ex command to execute the macro n number of times for each line in the file. After recording the macro, undo the changes done while ...
• 3,139
Accepted

### How to copy each line 11 times, incrementing the last "1" in each line from 2-12

Here's a substitution that solves the problem: :%s/\(.*\)1\(.*\)/\=join(map(range(1, 12), 'submatch(1) . v:val . submatch(2)'), "\n") The substitution matches each line that contains "1" and ...
• 871

### How to copy each line 11 times, incrementing the last "1" in each line from 2-12

Two ways: Use a macro! Starting with 1stlineblahblahblah/nt/1blah 2ndlineblahblahblah/nt/1blah 3rdlineblahblahblah/nt/1blah With your cursor on the first line qqyyp\$?\d<CR><Ctrl-a>q ...
• 1,470

### How to copy each line 11 times, incrementing the last "1" in each line from 2-12

I find it easiest to use macros for one-shot tasks like that. Just start recording a macro with q + name of register and do the task once. I see one repeatable task here: Select the line yank paste (...
• 249

### How to append a random number between a range [1,10] at the end of each line in vim

As long as you don't mind the quality of the random process generation: :%s/\s*\$/\=' ' . (1 + str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % 10)/ It basically replaces the end of ...
• 9,310
Accepted

### How to copy each line 19 times, incrementing two different numbers by 180?

You can record a macro, carry out your instructions, close the macro, then run it. In your case you may start with the cursor at the beginning of the line to copy. Press qa to start recording macro '...
• 146