1. 編譯和安裝vim74b(參考:http://t.cn/zQa8R7h )python
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)linux
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)git
>> ----a. 安裝管理插件的VIM插件(vunble)github
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
>> ----b. 下載YouCompleteMe至本地ubuntu
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
>> ----c. 配置vunble並安裝YounCompleteMevim
vim ~/.vimrc,往裏邊添加如下這段內容(示例):ruby
"""""""""""""""""""""""""""""" " 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',回車便可完成安裝bash
>> ----d. 手動編譯YouCompleteMe所依賴的ycm_core.so(這一部分須要前邊提示到的Clang)svn
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中加入ui
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 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! ;-) ]