Vim 中使用 OmniComplete 为 C/C++ 自动补全

来源:互联网 发布:路由器网络模式选哪个 编辑:程序博客网 时间:2024/04/29 03:14
(1) 解压 omnicppcomplete-0.41.zip 到目录 ~/.vim (unix) 或者 %HOMEPATH%\vimfiles (windows)

(2) 编辑 ~/.vimrc,增加如下内容
" ===== Set omnicppcomplete <C-X><C-O>, can get the option =====
" enable plugins
set nocp    
filetype plugin on
" --c++-kinds=+p  : Adds prototypes in the database for C/C++ files.
" --fields=+iaS   : Adds inheritance (i), access (a) and function signatures (S) information.
" --extra=+q      : Adds context to the tag name. Note: Without this option, the script cannot get class members.
" --languages=c++ : Builds only the tags for C++ files.
"        ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++ .
" add a map <C-F12>
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --languages=c++ .<CR>
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_DisplayMode = 1
let OmniCpp_ShowScopeInAbbr = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " 显示函数参数列表 
let OmniCpp_MayCompleteDot = 1   " 输入 .  后自动补全
let OmniCpp_MayCompleteArrow = 1 " 输入 -> 后自动补全 
let OmniCpp_MayCompleteScope = 1 " 输入 :: 后自动补全 
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
let OmniCpp_SelectFirstItem = 1
set completeopt=longest,menu

(3) 使用vim打开C++文档中只需要操作 <C-F12> 就可以自动创建并更新 tags 了

附注:
omnicppcomplete-0.41.zip 
下载地址:http://www.vim.org/scripts/script.php?script_id=1520
1 0
原创粉丝点击