值得注意的是目前插件还不能支持STL的补全,因为没用相应的tags文件,下面是相关解决办法:
http://www.sgi.com/tech/stl/download.html 下载stl.tar压缩包
#!/bin/bash mkdir stl2 mkdir stl3 cd stl for i in * do sed 's/__STL_BEGIN_NAMESPACE/namespace std{/' $i > ../stl2/$i done cd ../stl2 for i in * do sed 's/__STL_END_NAMESPACE/}/' $i > ../stl3/$i done cd ../stl3 ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ../stltags cd .. rm -rf stl2 rm -rf stl3此时已经生成了tags文件stltags,再将stltags移动到了~/.vim/tags/目录下(个人习惯),最后添加到vim的tags路径中。
c) vimrc 修改配置
let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 let g:miniBufExplMoreThanOne=0
function! <SID>ToggleWindowsManager() if IsWinManagerVisible() call s:CloseWindowsManager() else call s:StartWindowsManager() exe 'q' end endfunction现在再来体验效果,已经解决空文件问题^_^
不知不觉就写了这么长一篇了。。。给个最后的效果图
最后贴上vimrc:
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by " the call to :runtime you can find below. If you wish to change any of those " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim " will be overwritten everytime an upgrade of the vim packages is performed. " It is recommended to make changes after sourcing debian.vim since it alters " the value of the 'compatible' option. " This line should not be removed as it ensures that various options are " properly set to work with the Vim-related packages available in Debian. runtime! debian.vim " Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous " options, so any other options should be set AFTER setting 'compatible'. "set compatible " Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. if has("syntax") syntax on endif " If using a dark background within the editing area and syntax highlighting " turn on this option as well "set background=dark " Uncomment the following to have Vim jump to the last position when " reopening a file "if has("autocmd") " au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif "endif " Uncomment the following to have Vim load indentation rules and plugins " according to the detected filetype. "if has("autocmd") " filetype plugin indent on "endif " The following are commented out as they cause vim to behave a lot " differently from regular Vi. They are highly recommended though. "set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets. "set ignorecase " Do case insensitive matching "set smartcase " Do smart case matching "set incsearch " Incremental search "set autowrite " Automatically save before commands like :next and :make "set hidden " Hide buffers when they are abandoned set mouse=a " Enable mouse usage (all modes) " Source a global configuration file if available if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif set nu colo evening set cindent set tabstop=4 set shiftwidth=4 " Configure tags - add additional tags here or comment out not-used ones " load user definition tags set tags+=/home/hl/Coding/tags " Configure omnicppcomplete set nocp filetype plugin on " Configure TagList let Tlist_Show_One_File=1 let Tlist_Exit_OnlyWindow=1 " Configure winmanager nmap wm :WMToggle<CR> let g:winManagerWindowLayout="NERDTree|TagList" " Configure MiniBufExplorer let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 let g:miniBufExplMoreThanOne=0 " Configure NERDTree let g:NERDTree_title="[NERDTree]" function! NERDTree_Start() exec 'NERDTree' endfunction function! NERDTree_IsValid() return 1 endfunction
给vim安装完上述插件,易用人性不止增加了一点点,在vim下写代码已经比较顺手,已经有了VS的既视感,还有Linux下vim的高端感(可能刚开始还不太顺手),暂且vim就配置到这地方,后续有觉得好的再继续更新。
最后的最后,把上面提到的插件全部打了个包,方便以后大家下载:
http://download.csdn.net/download/mrknight/7155745