1. 编译和安装vim74b(参考:http://t.cn/zQa8R7h )
sudo apt-get install -y hgsvn libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby-dev mercurial cscope exuberant-ctagssudo apt-get remove vim vim-runtime gvim #这一步可以不做 cd ~ hg clone https://code.google.com/p/vim/ cd vim ./configure --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-gui=gtk2 --enable-cscope --prefix=/usr make VIMRUNTIMEDIR=/usr/share/vim/vim73 sudo make install sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1 sudo update-alternatives --set editor /usr/bin/vim sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1 sudo update-alternatives --set vi /usr/bin/vim
2. 编译Clang3_3(重点,参考:http://t.cn/zjD1V4d)
sudo apt-get install -y g++ subversion cmake cd ~ mkdir Clang && cd Clang svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm cd llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang cd ../../ mkdir build cd build ../llvm/configure --prefix=/usr/clang_3_3 --enable-optimized --enable-targets=host make -j 4 sudo make install export PATH=/usr/clang_3_3/bin:$PATH #这一句最好写到~/.bashrc内 # 至参考链接后边编译libcxx神马的,就与这里无关了(不过推荐编译和使用一下,尤其是试试它出错的时候,比gcc的提示好多了)
3. 编译和安装、使用YouCompleteMe(https://github.com/Valloric/YouCompleteMe)
>> ----a. 安装管理插件的VIM插件(vunble)
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
>> ----b. 下载YouCompleteMe至本地
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
>> ----c. 配置vunble并安装YounCompleteMe
vim ~/.vimrc,往里边添加以下这段内容(示例):
"""""""""""""""""""""""""""""" " Vunble """""""""""""""""""""""""""""" filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle Bundle 'gmarik/vundle' " vim-scripts repos Bundle 'Valloric/YouCompleteMe' filetype plugin indent on " required!
在VIM中输入 :BundleInstall,在弹出的界面中使用jk上下移动,定位至Bundle 'Valloric/YouCompleteMe',回车即可完成安装
>> ----d. 手动编译YouCompleteMe所依赖的ycm_core.so(这一部分需要前边提示到的Clang)
cd ~ mkdir ycm_build cd ycm_build cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/clang_3_3/ . ~/.vim/bundle/YouCompleteMe/cpp make ycm_core cp /usr/clang_3_3/lib/libclang.so ~/.vim/bundle/YouCompleteMe/python/libclang.so #这一步是为了使用新的libcang.so
>> ----e. 配置补全,在vimrc中加入
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " YouCompleteMe """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
提示:一些比较大的项目,它索引结构体成员,索引类成员等会比较慢,会显示:No completions found; errors in the file?[just wait a moment, all are perfect! ;-) ]