问题描述:

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.

网友答案:

By pieces:

  • "0P - Paste the originally yanked line from register 0. As read in http://unix.stackexchange.com/a/26716
  • dd - delete current line

So this replaces the current line with the yanked block.

相关阅读:
Top