我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
我一直在Vim中学习新的命令,但我相信每个人都偶尔会学习一些新东西。我最近才知道:
Zz, zt, zb -位置光标在中间,顶部或底部的屏幕
还有什么其他有用或优雅的命令是你希望很久以前就学会的?
当前回答
^r^w以命令模式将单词粘贴到光标下。
它在使用grep或replace命令时非常有用。
其他回答
我刚刚在浏览Vim帮助时发现了这个:
:help index
这将把您带到一个单独的(可搜索的!)页面,其中包含所有模式的所有命令。
所以,如果你知道你要记住/学习的命令是从某个按键开始或涉及到某个按键,你可以搜索并浏览所有的可能性。或者你可以浏览你感兴趣的模式,看看/学习编辑的可能性。
我都数不清有多少次我只是按Ctrl + R或者其他键,然后得到了第一个东西,当然这不是你想要的。在我看来,这比:helpgrep好多了。
然后进入。vimrc:
nnoremap <silent> <F1> :help normal-index<CR>
inoremap <silent> <F1> <C-O>:help insert-index<CR>
:help仍然会让你进入默认的F1页面。
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.
vimcryption
vim -x文件。txt
您将被要求输入密码,编辑并保存。现在,无论何时在vi中再次打开该文件,都必须输入密码才能查看。
:Te[xplore]
Tab & Explore(在生成浏览器窗口之前执行Tab new)
^X-F使用当前目录中的文件名完成。不再从终端复制/粘贴或痛苦的双重检查。
^X-P使用当前文件中的单词完成
:set scrollbind强制一个缓冲区与另一个缓冲区一起滚动。例如,把你的窗户分成两个垂直的窗格。在每个文件中加载一个文件(可能是同一文件的不同版本)。Do:设置每个scrollbind。现在,当你滚动其中一个窗格时,两个窗格将一起滚动。比较文件的理想选择。