我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
当前回答
:q!
我希望我在第一次使用vi之前就知道这一点。
其他回答
这句话总是让我高兴起来:
:help 42
进一步使用xcramps的建议,我无法告诉你我用了多少次:
: % !排序
对文件中的项列表进行排序。
细节:
:范围!命令
将在指定的行范围上执行shell命令。一个范围通常被指定为开始,结束
例子: 1,3指定前3行 'a,'b选择书签a和b之间的文本 ,$选择整个文档(。=第一线;$ =最后一行) %是.,$的快捷方式,还可以选择整个文档。
您可以随意混合和匹配数字、书签、.和$。
我真的希望我知道你可以使用Ctrl+C而不是Esc来切换插入模式。这对我来说是一个真正的生产力提升。
ZZ(工作方式:wq)
关于光标的位置:我发现光标总是停留在屏幕中间是很酷的
set scrolloff=9999
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.