I need to create a file in vi with this pattern. Is there a way to auto generate these lines using the first line
run 1 end
run 2 end
run 3 end
run 4 end
run 5 end
run 6 end
I can always do this in excel and then convert it to a text file and then switch to vi, but wanted to know if there a way to do it in vi so that I don’t have to switch back to excel
:help ctrl-a^a increments the number under the cursor, which you can use in a macro. For your case, assuming you have the first line and the cursor is on it:
Should do the trick. This is the technique outlined in the help pages, modified with
wto move the cursor forward to the number. Breaking it down:qastart recording a macro in registeraYyank the current linepput the yank buffer below the current position and move to column 1 of the new rowwmove forward one word (to the number)^aincrement the numberqstop recording the macro<count>@aapply the macro <count> timesAnother technique is to use an external tool. For example, if you already have the line and the cursor is on it: