A macro is probably the easiest way. Place the cursor at the beginning of the first line and record by making it one. Then you can run the macro over many lines. For example, this will pass arg for the echo and replace the results in the string with an argument. Enter them with the cursor somewhere in the first line of commands.
qa0y$:r!echo <Cr>"<Enter>kddjq
This line wrote the macro to register a (qa), moved to the beginning of line (0), copied the entire line (y $), switched to command line mode (:), read the result of the command to the line below your (r! Echo .. ..), Cr followed by "inserts your text into the command: r, k moved you back to the original line, dd deleted the line, j moved you to the next line (should contain the next command), and then stop writing (q) .
Now you can run the macro on each line either by pressing @a (after that, as soon as @@ repeats the last run macro) or by clicking on the number of times you want to run the 5 @a macro. Or better yet, select the lines and press: norm! @a
It seems like when you enter text, but when you get used to macros, they save real time savings. You basically do what you want on the first line, and then again vim replay your strokes. To solve this problem, a little practice is required, like a set of repeated tasks, but this is not what we are doing anyway :)
source share