安装 Vundle   由于 vim 缺乏默认的插件管理器,所有插件的文件都散布在 ~/.vim 下的几个文件夹中,这样导致各种插件的安装、更新、删除都需要自己手动处理,既麻烦费事,又可能出现错误。所以我们需要插件管理器的帮忙,常见的插件管理器有 vundle、pathogen 等等,我们这里使用 vundle。   Vundle 托管在 Github 上,所以使用 git 下载 vundle ,并将其存放于 ~/.vim/bundle/vundle 即可。使用如下命令直接将源代码检出到该目录: 
  
1 $ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 
 
  下载完了 vundle 后,还需要配置 .vimrc 文件。   为了不让 .vimrc 看起来太臃肿,我是新建了一个 ~/.vimrc.bundles 文件来保存所有插件的配置。先在 ~/.vimrc.bundles 文件中包含如下内容:
1 2 3 filetype off   set rtp+=~/.vim/bundle/vundle/ call vundle#rc() 
 
  然后在 ~/.vimrc 文件中加入内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 if  filereadable(expand("~/.vimrc.bundles" ))  source ~/.vimrc.bundles  endif set runtimepath^=~/ .vim/bundle/ctrlp.vim  filetype off set  rtp+=~/.vim/bundle/vundle/call vundle#rc() filetype plugin indent on   map <C-n> :NERDTreeToggle<CR> set  nu  highlight LineNr cterm=bold ctermfg=red highlight StorageClass cterm=bold ctermfg=darkgreen highlight Type cterm=bold ctermfg=blue highlight LineNr cterm=bold ctermbg=black highlight phpStructure cterm=bold ctermfg=darkred highlight phpFunctions cterm=bold ctermfg=256 highlight Title ctermfg=blue  highlight pythonString cterm=bold ctermfg=gray highlight pythonFunction cterm=bold  highlight pythonInclude cterm=bold ctermfg=lightblue highlight javaScriptStringS ctermfg=gray  highlight String ctermfg=gray hi Search cterm=NONE ctermfg=darkred ctermbg=yellow cterm=reverse   set  hlsearchset  backspace=2set  rulerset  showmodesyntax on     set  smartindent  set  tabstop=4  set  shiftwidth=4  set  expandtab  set  softtabstop=4
 
安装插件 以“用户名/repos名”的方式。我们这里将插件的配置信息放在 ~/.vimrc.bundles,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 filetype off   set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " Define bundles via Github repos " Bundle 'christoomey/vim-run-interactive' Bundle 'Valloric/YouCompleteMe' Bundle 'croaky/vim-colors-github' Bundle 'danro/rename.vim' Bundle 'majutsushi/tagbar' Bundle 'kchmck/vim-coffee-script' Bundle 'kien/ctrlp.vim' Bundle 'pbrisbin/vim-mkdir' Bundle 'scrooloose/syntastic' Bundle 'slim-template/vim-slim' Bundle 'thoughtbot/vim-rspec' Bundle 'tpope/vim-bundler' Bundle 'tpope/vim-endwise' Bundle 'tpope/vim-fugitive' Bundle 'tpope/vim-rails' Bundle 'tpope/vim-surround' Bundle 'vim-ruby/vim-ruby' Bundle 'vim-scripts/ctags.vim' Bundle 'vim-scripts/matchit.zip' Bundle 'vim-scripts/tComment' Bundle 'mattn/emmet-vim' Bundle 'scrooloose/nerdtree' Bundle 'Xuyuanp/nerdtree-git-plugin' Bundle 'Lokaltog/vim-powerline' Bundle 'godlygeek/tabular' Bundle 'msanders/snipmate.vim' Bundle 'jelera/vim-javascript-syntax' Bundle 'altercation/vim-colors-solarized' Bundle 'othree/html5.vim' Bundle 'xsbeats/vim-blade' Bundle 'Raimondi/delimitMate' Bundle 'groenewege/vim-less' " Bundle 'evanmiller/nginx-vim-syntax' Bundle 'Lokaltog/vim-easymotion' Bundle 'tomasr/molokai' Bundle 'klen/python-mode' 
 
接着,打开 vim,输入 :BundleInstall 或者直接在终端输入 vim +BundleInstall +qall 安装插件。
YouCompleteMe 安装YouCompleteMe的步骤
用vundle中的安装太慢,所以自己手动安装 检查是否安装clang、g++、cmake等 安装插件管理工具
1 git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 
 
在.vimrc中插件管理处加入:
'Valloric/YouCompleteMe'```  
cd .vim/bundle git clone https://github.com/Valloric/YouCompleteMe.git  cd YouCompleteMe git submodule update –init –recursive ./install.py –clang-completer
 
fatal: unable to access ‘https://go.googlesource.com/tools/' : Failed to connect to go.googlesource.com port 443: 连接超时 fatal: 无法克隆 ‘https://go.googlesource.com/tools'  到子模组路径 ‘/home/zyj/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools’
1 2 3 原因 go.googlesource.com 域名国内无法直接访问,这时候根据 后面的路径  /home/zyj/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools 来知道该模块是要放这个路径下的 到 github 上找到该模块下载到该路径 
 
cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x git clone https://github.com/golang/tools.git 
1 2 回到 YouComplateMe 目录继续安装其他子模块 
 
cd ~/.vim/bundle/YouCompleteMe
继续子模块的安装 git submodule update –init –recursive
 
cd ~
创建一个目录用来存放接下来要编译的代码的目录 mkdir ~/.ycm_build
进入目录 cd ~/.ycm_build
编译输出到当前目录(.ycm_build) 1 cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp 
 
2.1 如果需要实用 C 语言家族的相关功能(我这里系统自带 llvm 3.8、clang 3.8、libclang 没有、libboost-all-dev 没有),不需要则直接跳过 2.1
1 sudo apt install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev 
 
2.2 编译 YouComplateMe
1 # 跳过了 2.1 执行<br>cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp<br><b 
 
在.vimrc中添加下列
1 let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'