概述:OmniCppComplete适用于vim7.0及以上,OmniCppComplete利用catags产生的数据库实现C/C++的代码自动补全功能。
一、OmniCppComplete 特点:
- Complete namespaces, classes, structs and union members.- Complete inherited members for classes and structs (single and multiple inheritance).
- Complete attribute members eg: myObject->_child->_child etc...
- Complete type returned by a function eg: myObject->get()->_child.
- Complete the "this" pointer.
- Complete a typedef.
- Complete the current scope (global and class scope).
- Complete an object after a cast (C and C++ cast).
- Complete anonymous types (eg: struct {int a; int b;}g_Var; g_Var.???). It also works for a typedef
二、 安装步骤:
1、安装OmniCppComplete。可以到OmniCppComplete的官方下载:点击打开链接,有时可能除了翻墙没法打开。可以从这个地方下载:点击打开链接。具体参考安装目录doc/omnicppcomplete.txt。
2、新建一个保存ctags数据库的目录,例如在安装目录下新建一个tags目录。
3、创建stdc++ tags:下载解压modified libstdc++ headers 到 tags/cpp_src。官方下载链接:点击打开链接,或者:点击打开链接。stdc++ tags介绍:能够被ctags使用的被稍做了修改的libstdc++头文件,从stdc++头文件建立的ctags数据库被OmniCppComplete来实现STL、流以及其他标准C++内容的补全功能 。
4、建立stdc++的catags数据库:
4.1 转到tags目录
4.2 运行:
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f cpp cpp_src
5、增加额外的tags:
$ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f gl /usr/include/GL/ # for OpenGL
$ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f sdl /usr/include/SDL/ # for SDL
$ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f qt4 /usr/include/qt4/ # for QT4
6、编辑vimrc配置文件:
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/cpp
set tags+=~/.vim/tags/gl
set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4
" build tags of your own project with Ctrl-F12
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
1349



被折叠的 条评论
为什么被折叠?



