When using :s, how do I multiply the string being written by an integer, to write N copies of it?
For example, :s/pattern/10*\r/
would write 10 carriage returns in each match.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityWhen using :s, how do I multiply the string being written by an integer, to write N copies of it?
For example, :s/pattern/10*\r/
would write 10 carriage returns in each match.
You can use repeat
function with replace expression:
%s/\n\_s*$/\=repeat("\r", 10)
Check :h sub-replace-expression
and :h repeat()
for details.
:substitute