let g:acp_completeoptPreview = 1
5,注释管理
常见的注视管理插件为 The NERD Commenter,默认支持多种语言,使用方法:
在可视模式(V)下选择一段代码,使用\cc添加逐行注释;\cu取消注释;\cm添加块注释
6,代码的浏览与跳转(与IDE中的crtl-点击的功能相同)
简单跳转
在命令模式下直接使用一下命令
跳转到定义:gd跳转到局部变量的定义,gD跳转到全局变量的定义
搜索:*/#可对光标处的词向前/向后做全词搜索,g*/g#对光标处的次做向前/向后的非全词匹配搜索
代码块首尾:[[/]]可跳到当前代码块的开始/结束的位置;%可在配对的代码括号或代码块的首尾之间跳转
历时位置:crtl-O在历史记录中后退;crtl-I在历史记录中前进
基于代码理解的跳转
需要依赖ctafs插件
安装插件后,在代码的目录下运行
ctags -R
即可获得描述代码结构的tag文件
并设置
set tags=tags:/
设置好后,可在vim中使用如下功能:
Ctrl-]转至最佳匹配的相应Tag
Ctrl-T返回上一个匹配
g Ctrl-]可显示所有备选的tags
7,查看代码框架
如想查阅代码的大体结构,如类,函数变量等,可使用插件taglist,配置如下
" F4: 使用F4开关taglist
nnoremap <silent> <F4> :TlistToggle<CR>
"let Tlist_Show_One_File = 1 " Displaying tags for only one file~
let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
"let Tlist_Use_Right_Window = 1 " split to the right side of the screen
let Tlist_Sort_Type = "order" " sort by order or name
let Tlist_Display_Prototype = 0 " do not show prototypes and not tags in the taglist window.
let Tlist_Compart_Format = 1 " Remove extra information and blank lines from the taglist window.
let Tlist_GainFocus_On_ToggleOpen = 1 " Jump to taglist window on open.
let Tlist_Display_Tag_Scope = 1 " Show tag scope next to the tag name.
"let Tlist_Close_On_Select = 1 " Close the taglist window when a file or tag is selected.
let Tlist_Enable_Fold_Column = 0 " Don't Show the fold indicator column in the taglist window.
let Tlist_WinWidth = 40
" let Tlist_Ctags_Cmd = 'ctags --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++'
" very slow, so I disable this
" let Tlist_Process_File_Always = 1 " To use the :TlistShowTag and the :TlistShowPrototype commands without the taglist window and the taglist menu, you should set this variable to 1.
":TlistShowPrototype [filename] [linenumber]