1. 安装必要组件
sudo apt-get install 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 checkinstall
2. 升级Vim 到7.4
手动添加PPA(Personal Package Archives)
sudo add-apt-repository ppa:nmi/vim-snapshots
sudo apt-get update
sudo apt-get install vim
3. 安装llvm & clang
到 http://llvm.org/releases/download.html#3.3 下载编译后的二进制文件
http://llvm.org/releases/3.3/clang+llvm-3.3-amd64-Ubuntu-12.04.2.tar.gz
解压到/
tar -zxf clang3.3-amd64-Ubuntu-12.04.2.tar.gz
cd clang+llvm-3.3-amd64-Ubuntu-12.04.2/
cp -r * /
或者sudo apt-get install clang3.3
如果在命令行输入clang,输出clang: error: no input files,说明安装成功
4. 下载 Vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Vundle可以让Vim自动从github等地方下载插件,而不用每次去vim.org上手动下载
修改.vimrc
set nocompatible " be iMproved
set nu
set noswapfile
syntax on
set backspace=2
set tabstop=2
set shiftwidth=2
set completeopt=menu
:colorscheme ron
set cindent
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe'
Bundle 'scrooloose/syntastic'
""""""""""syntastic""""""""""""
let g:syntastic_check_on_open = 1
let g:syntastic_cpp_include_dirs = ['/usr/include/']
let g:syntastic_cpp_remove_include_errors = 1
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_compiler = 'clang++'
"set error or warning signs
let g:syntastic_error_symbol = 'x'
let g:syntastic_warning_symbol = '!'
"whether to show balloons
let g:syntastic_enable_balloons = 1
""""""""""""YCM""""""""""""""""""""
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_confirm_extra_conf = 0
5. 编译ycm_core & ycm_support_libs
cd ~
mkdir ~/ycm_build
cd ~/ycm_build
cmake -G "Unix Makefiles" ~/.vim/bundle/YouCompleteMe/cd ~
mkdir ~/ycm_build
cd ~/ycm_build
cmake -G "Unix Makefiles" ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp -DEXTERNAL_LIBCLANG_PATH=/lib/libclang.so
make ycm_core
make ycm_support_libs
这里要注意的是-DEXTERNAL_LIBCLANG_PATH这个参数,用于指定libclang.so的位置
6. 配置.ycm_extra_conf.py
~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py
在这个文件的flags尾部添加:
'-isystem',
'/usr/include',
'-isystem',
'/usr/include/c++/'
wget http://www.vim.org/scripts/download_script.php?src_id=17123 -O nerdtree.zip
unzip nerdtree.zip
mkdir -p ~/.vim/{plugin,doc}
cp plugin/NERD_tree.vim ~/.vim/plugin/
cp doc/NERD_tree.txt ~/.vim/doc/
vim ~/.vimrc
然后添加
" NERDTree
map <F10> :NERDTreeToggle<CR>
taglist插件:
1.sudo apt-get install ctags
2. taglist插件是以vim脚本的形式存在,因此只需要将其下载下来放到相应的目录即可。taglist基于ctags才能发挥作用,因此在使用taglist之前,确保已经安装了ctags。具体安装方法如下:
下载地址(两个可选择任意一个):
Official site http://vim-taglist.sourceforge.net/
VIM online http://www.vim.org/scripts/script.php?script_id=273
下载解压后,将插件脚本文件(.vim)和帮助文件(.txt)分别放入vim常用目录:
$HOME/.vim/ 或
$HOME/vimfiles/ 或
$VIM/vimfiles/
下的
plugin/taglist.vim
doc/taglist.txt
中。