人们谈论常见技巧的问题很多,特别是“Vim+ctags提示和技巧”。

然而,我并没有提到Vim新手会觉得很酷的常用快捷方式。我所说的是一位经验丰富的Unix用户(无论是开发人员、管理员,还是两者都有),他们认为自己知道99%的人从未听说过或梦想过的东西。这不仅让他们的工作更容易,而且很酷,很粗糙。毕竟,Vim位于世界上最黑暗的角落丰富的操作系统中,因此它应该具有只有少数特权人士知道并想与我们分享的复杂性。


当前回答

==========================================================
In normal mode
==========================================================
gf ................ open file under cursor in same window --> see :h path
Ctrl-w f .......... open file under cursor in new window
Ctrl-w q .......... close current window
Ctrl-w 6 .......... open alternate file --> see :h #
gi ................ init insert mode in last insertion position
'0 ................ place the cursor where it was when the file was last edited

其他回答

:设置本地自动读取

自动重新加载当前缓冲区。。在查看日志文件时特别有用,它几乎可以从vim中为unix中的“tail”程序提供功能。

从vim中检查编译错误。根据perl语言设置makeprg变量

:setlocal makeprg=perl\-c\%

对于PHP

设置makeprg=php\-l\%设置错误格式=%m\\%f\\line\%l

发出“:make”将运行相关的makeprg,并在快速修复窗口中显示编译错误/警告,并可以轻松导航到相应的行号。

:! [command]在Vim中执行外部命令。

但是在冒号后面加一个点:。![command],它会将命令的输出转储到当前窗口中。那就是:!

例如:

:.! ls

我经常使用此功能,例如将当前日期添加到我正在键入的文档中:

:.! date

映射F5以快速ROT13缓冲区:

map <F5> ggg?G``

您可以将其用作boss密钥:)。

有时,.vimrc中的设置会被插件或自动命令覆盖。要调试这一点,一个有用的技巧是将:verbose命令与:set结合使用。例如,要确定cindent在何处设置/取消设置:

:verbose set cindent?

这将输出如下内容:

cindent
    Last set from /usr/share/vim/vim71/indent/c.vim

这也适用于地图和高光。(感谢joeytwiddle指出这一点。)例如:

:verbose nmap U
n  U             <C-R>
        Last set from ~/.vimrc

:verbose highlight Normal
Normal         xxx guifg=#dddddd guibg=#111111 font=Inconsolata Medium 14
        Last set from ~/src/vim-holodark/colors/holodark.vim