Reputation: 5462
I'm doing a Vimgolf problem to transform this:
First:
Junk text.
Second:
Junk text.
Third:
Junk text.
Last:
Copy these lines,
and replace the text
in each heading above.
to this:
First:
Copy these lines,
and replace the text
in each heading above.
Second:
Copy these lines,
and replace the text
in each heading above.
Third:
Copy these lines,
and replace the text
in each heading above.
Last:
Copy these lines,
and replace the text
in each heading above.
One solution is:
:8,$y<CR>:g/J/norm dd"0P<CR>ZZ
What is :g/J/norm dd"0P
doing? I understand that "J" joins lines, and ":g" is global, but I don't understand the rest.
Upvotes: 1
Views: 132
Reputation: 61
By pieces:
"0P
- Paste the originally yanked line from register 0. As read in https://unix.stackexchange.com/a/26716dd
- delete current lineSo this replaces the current line with the yanked block.
Upvotes: 6