这只是中间的vimgolf挑战在做什么?

时间:2016-02-29 06:38:02

标签: vim

所以在工作http://www.vimgolf.com/challenges/54862fbb3f90ac0002904cf5时,一个解决方案是:

)3:wq!<CR>

我的vim备忘单说:

)&#34;结束句&#34;。不确定&#34; 3&#34;适合。

但是&#34; wq!&#34;我知道写/退出。

这组击键是做什么的?

2 个答案:

答案 0 :(得分:6)

<强>命令

)3:wq!<CR>

<强>输入

Leave only the
numbered lines.
LINE 1
LINE 2
LINE 3
That's all.
Thank you
very much.

<强>击穿

)      goes one sentence forward. This positions the cursor at LINE 1
3      starts a range of 3 lines for the next command. 
:wq!   writes the range to the file. 
       You should notice that when typing :, the range get's set to .,.+2

我不确定将:放在从正常模式切换到命令模式的位置,因此在分解后同样有效

)      goes one sentence forward. This positions the cursor at LINE 1
3:     starts a range of 3 lines and enters command line mode
wq!    writes the range to the file. 
       You should notice that when typing :, the range get's set to .,.+2

答案 1 :(得分:3)

  • )将光标放在LINE 1上当前句子之后。

  • 3:command由Vim扩展为:.,.+2command,这意味着&#34;在当前行上执行command以及下一行&#34;。

  • .,.+2wq!只将给定的行写入文件,有效地从缓冲区/文件中删除任何其他行。

请参阅:help range:help :write