10

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 recording, or there will be n + 1 additional lines for the first line, and n for consecutive lines. Record the macro to the a register with qayyp$?\d<CR><...


8

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 captures the text before {c1} and after {c2} the last "1". For each matched line, the range of numbers from one to twelve {n} are mapped to create twelve lines of the ...


6

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 10@q Which does: qq Start recording a macro into the q register yyp yank the current line, and paste it below $?\d<CR> Go to the end of the line, and ...


5

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 (will put you in the next line) go to end of line go back one word increment by one Now record the required keystrokes to register a, in normal mode: qayyp$b&...


3

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 each line, and all the trailing spaces, with a single space followed by (current time microseconds % 10) + 1, where % is the remainder/modulo operation. random ......


3

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 'a' (you can pick any letter, but beware these are the same registers as the copy-paste registers). Then carry out your actions: copy the line yy, paste it p, ...


2

Save the following macro and use it for each line: qqyy11p/\/\zs1<CR><C-v>10jg<C-a>q The main difference over the other answers is that this makes use of g<C-a> on a column selection that increments each line with a different number. Check :help v_g_CTRL-A for more information. I've also used \zs to select the pattern start position,...


Only top voted, non community-wiki answers of a minimum length are eligible