【简介】
当ctags使用ctags -R的命令,总是只能打出c的tag,但是c++的tag不能打出来,
所以用<C-P>,<C-x><C-o>,不太好使。
所以需要用到vim插件,omnicppcomplete(需要vim7.1以上)。
【omnicppcomplete下载地址】
omnicppcomplete: http://www.vim.org/scripts/script.php?script_id=1520(new-omni-completion(全能补全))
【安装方法】
install details
1) Unzip the plugin to ~/.vim (unix) or %HOMEPATH%\vimfiles (windows)
2) Run Vim and type the following command :
:helptags $HOME/.vim/doc
or
:helptags $HOME/vimfiles/doc
【在vimrc配置】
在vimrc末尾加入如下命令( Type :h omnicppcomplete and please read the installation paragraph):
let OmniCpp_GlobalScopeSearch = 1 " 0 or 1
let OmniCpp_NamespaceSearch = 1 " 0 , 1 or 2
let OmniCpp_DisplayMode = 1
OmniCpp_ShowScopeInAbbr = 0
let OmniCpp_ShowPrototypeInAbbr = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 1
【如何打tags】
shell下执行如下命令:
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
就产生了tags文件。
【如何使用tags】
方法1、把tags文件放在工程的根目录,这样当vim从根目录启动时就能自动找到
方法2、在vim里面执行如下命令:
:set tags=/workspace/Server/Rel0.8.2/HomeServer/src/release/tags
:set tags+=/workspace/Server/Rel0.8.2/HomeServer/src/release/tags.lib
vim就能找到这些tags。
【如何查看vim里面的tag设置】
在vim下打入如下命令:
:set tags
就能看到tags设定。
【如何方便的使用tags】
在每次启动vim都要,设置tags,很费劲的。所有想了一下方法,来使用tags。
1、在vimrc末尾加入如下代码:
:if getfsize(".vimscript")>0
source .vimscript
:endif
这样vim在启动的时候就会自动加载,.vimscipt的文件的里面的vim命令。
2、在工程的根目录下,编辑.vimscript文件,加入如下代码:
:set tags=/workspace/Server/Rel0.8.2/HomeServer/src/release/tags
:set tags+=/workspace/Server/Rel0.8.2/HomeServer/src/release/tags.lib
3、在工程的根目录启动vim时,就会自动加载,.vimscript的配置。这样就很方便了。
原文地址:http://blog.csdn.net/dyoldfish/archive/2007/11/27/1904005.aspx
















