我正在做一个Vimgolf问题来改变这个:
First:
Junk text.
Second:
Junk text.
Third:
Junk text.
Last:
Copy these lines,
and replace the text
in each heading above.
到此:
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.
一个解决方案是:
:8,$y<CR>:g/J/norm dd"0P<CR>ZZ
:g/J/norm dd"0P
在做什么?我知道“J”加入了行,“:g”是全局的,但我不了解其余部分。
答案 0 :(得分:6)
By pieces:
"0P
- Paste the originally yanked line from register 0. As read in https://unix.stackexchange.com/a/26716 dd
- 删除当前行所以这会将当前行替换为yanked块。