Use a tool that makes it easy:
%!awk '{ <c-r>=repeat('print;', 5)<cr> }'
Here I’m using awk with an action to print the current line multiple times, which I created by invoking vim’s repeat
function and inserting into the command using the expression register.
This is scalable: you can use a range to select a subset of lines (although for a single line yy{count}p
is faster), and it’s adjustable (change the repeat parameter). It is limited to systems where you have awk
, though.
Alternately, with an awk-loop:
%!awk '{ for (i = 0; i < 5; ++i) print; }'
More approaches: https://unix.stackexchange.com/questions/81904/repeat-each-line-multiple-times
I can’t resist this very terse polyglot:
%!awk '<c-r>=repeat('1;', 5)<cr>'