我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
当前回答
Don't press Esc ever. See this answer to learn why. As mentioned above, Ctrl + C is a better alternative. I strongly suggest mapping your Caps Lock key to escape. If you're editing a Ctags compatible language, using a tags file and :ta, Ctrl + ], etc. is a great way to navigate the code, even across multiple files. Also, Ctrl + N and Ctrl + P completion using the tags file is a great way to cut down on keystrokes. If you're editing a line that is wrapped because it's wider than your buffer, you can move up/down using gk and gj. Try to focus on effective use of the motion commands before you learn bad habits. Things like using 'dt' or 'd3w' instead of pressing x a bunch of times. Basically, any time that you find yourself pressing the same key repeatedly, there's probably a better/faster/more concise way of accomplishing the same thing.
其他回答
直到[character] (t)。它适用于任何接受范围的命令。我最喜欢的是ct;或ct),它会删除尾随分号/右括号之前的所有内容,然后将您置于插入模式。
另外,G和gg也很有用(分别转到底部和顶部)。
Gi切换到插入模式,将光标放置在先前的相同位置。
我的Vim脑库中最近添加的一些内容:
^wi:通过分割窗口跳转到光标下的标签。 cib/ cib:分别更改当前括号()或大括号{}集合内的文本。 :set listchars=tab:>-,trail:_ list:显示不同于其他空格的制表符/尾随空格。它对Python编码有很大帮助。
我不得不说,我最喜欢的一个方法是把帮助窗口放在一个新标签中:
:tab help <help_topic>
这将在一个新标签中打开帮助,作为一个喜欢Vim标签的人,这是非常有用的。
我很惊讶没有人提到Vim的窗口支持。我几乎每次打开Vim都会使用Ctrl + W, S。