如何解读这个VimGolf的答案?

时间:2013-12-21 06:26:16

标签: vim

the VimGolf challenge

自:

Make the pairs of lines match up by making each second line same as first:

# Appending text:
The name "Vim" is an acronym for "Vi IMproved"
The name "Vim" is an acronym for

# Editing text:
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga
Trivia: Vim is a text editor released by Bram Moolenaar in 1991 for the Amiga

# Deleting text:
Vim has a vi compatibility mode
Vim has a vi compatibility mode but when not in this mode Vim has many enhancements over vi

要:

Make the pairs of lines match up by making each second line same as first:

# Appending text:
The name "Vim" is an acronym for "Vi IMproved"
The name "Vim" is an acronym for "Vi IMproved"

# Editing text:
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga
Vim is a text editor originally released by Bram Moolenaar in 1991 for the Amiga

# Deleting text:
Vim has a vi compatibility mode
Vim has a vi compatibility mode

需要最少按键的最佳答案之一是:

:g/v/t.|+d<CR>ZZ

我试图理解为什么这项工作。在此上下文中v.|的含义是什么?此外,我在哪里可以找到:help中的相关部分?

感谢。

1 个答案:

答案 0 :(得分:5)

:g/v/command

在与command匹配的每一行上执行v

:t.

将当前行复制到自身下方。

之后,删除原来的“第二行”。

简而言之,该解决方案的作者开箱即用:不是操纵第二行,而是简单地复制第一行并删除第二行。

至于文件:

:help :g
:help :t