In vim, how can I paste multiple lines of code after every line of a visual block?
What I have is:
foo bar 1 2 3 What I am trying to do is:
1 foo bar 2 foo bar 3 foo bar Is there a way to easily accomplish this?
In vim, how can I paste multiple lines of code after every line of a visual block?
What I have is:
foo bar 1 2 3 What I am trying to do is:
1 foo bar 2 foo bar 3 foo bar Is there a way to easily accomplish this?
You can cut it to the default register and do a global replacement for the rest of lines, like this:
Go to first column of first line of the file:
gg0 Cut data:
3dd Do a global repeat for every line of the file and paste it:
:g/^/put It yields:
1 foo bar 2 foo bar 3 foo bar Not fully automated but almost there:
Visually highlight desired rows to copy with Shift+V
Delete with d
Move to first line ("1") and start recording with q followed by some letter, i.e., a.
Paste with p and then move down to the next line ("2"). Stop recording with q.
Now just repeat the last recorded command with @@, or + the designated letter, i.e., @a.