系统:ubuntu 11.10
软件 vim ctags
插件:
ctags .vim: http://www.vim.org/scripts/script.php?script_id=610
code_complete.vim : http://www.vim.org/scripts/script.php?script_id=1764
taglist.vim : http://www.vim.org/scripts/script.php?script_id=273
OmniCppComplete.vim : http://www.vim.org/scripts/script.php?script_id=1520 (安装方法:http://zhenyaliu.blog.163.com/blog/static/237757192010101785512931/)
tags for std c++ : http://www.vim.org/scripts/script.php?script_id=2358
注意:上面这些插件放的位置都在 $HOME/.vim/文件夹下(没有,则自己创建)
其中OmniCppComplete里面解压出来的东西After等文件夹直接放到$HOME/.vim/文件夹下面
别的几个插件都放分别放到$HOME/.vim/plugin 和 $HOME/.vim/doc 文件夹下
其中tags for std c++里面解压出来的cpp_src放到$HOME/.vim/tags文件夹中
然后按照这个里面生成tags文件:http://vim.wikia.com/wiki/C++_code_completion
安装的时候,按照这个里面的说明。其中 $HOME/.vimrc 文件内容如下:
这里面是用 “ 来作注释 ,不是 #
(把这些插件放好位置后,编辑 自己主目录下的 .vimrc文件(没有,则自己创建)
(最终 .vimrc文件如下。 上面的网址是用来参考别的安装步骤的)
syntax on set tabstop=4 set softtabstop=4 set shiftwidth=4 set autoindent set cindent set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s set nu if &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dm endif let g:ctags_path="/usr/bin/ctags" let g:ctags_statusline=1 let g:ctags_title=1 let g:generate_tags=1 let g:ctags_regenerate=1 let Tlist_File_Fold_Auto_Close=1 "configure tags - add additional tags here or comment out not-used ones" set tags+=~/.vim/tags/cpp " 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 " set the filetype to cpp format(when using c++) set nocp filetype plugin on 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
(我也是找了无数资料才弄出这种效果,,希望大家少走弯路!~
就可以实现这个里面的效果了:
转载注明出处:http://blog.csdn.net/fdl19881/article/details/7275203