周梦康 发表于 2019-09-22 382 次浏览 标签 : Vim

安装也非常简单

" 按下F3自动补全代码,注意该映射语句后不能有其他字符,包括tab;否则按下F3会自动补全一些乱码
imap <F3> <C-X><C-O>
" 按下F2根据头文件内关键字补全
imap <F2> <C-X><C-I>
" set completeopt=menu,menuone " 关掉智能补全时的预览窗口
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window
let OmniCpp_GlobalScopeSearch=1 " enable the global scope search
let OmniCpp_DisplayMode=1 " Class scope completion mode: always show all members
"let OmniCpp_DefaultNamespaces=["std"]
let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column
let OmniCpp_ShowAccess=1

该插件也依赖 ctags

与之类似的还有 AutoComplPop https://www.vim.org/scripts/script.php?script_id=1879 安装也非常简单。效果如下

AutoComplPop 会自动出现下拉提示,仅仅是提示当前文件中编辑出现过的函数名,如果要调用本文件之外的所有包含的ctags里面的函数,还是使用 OmniCppComplete 吧。

vim 我就不弄太复杂了,就这样吧。

评论列表