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

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


当前回答

有时,.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

其他回答

我今天通过NSFAQ找到了这个:

注释代码块。

点击CTRL-V进入分块视觉模式。

标记要注释的块。

点击I(大写I)并在行的开头输入注释字符串。(//对于C++)

按ESC键,所选的所有行都将//前置到行的前面。

使用鼠标右键切换gVim中的插入模式,设置如下在~/.gvimrc中:

"
"------------------------------------------------------------------
" toggle insert mode <--> 'normal mode with the <RightMouse>-key
"------------------------------------------------------------------
nnoremap  <RightMouse> <Insert>
inoremap  <RightMouse> <ESC>
"
==========================================================
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
gv

重新选择上次视觉选择。

映射F5以快速ROT13缓冲区:

map <F5> ggg?G``

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