vim配置补全插件YouCompleteMe

时间:2022-08-13 17:23:00

系统环境:
Ubuntu 14.04
Vim 7.4.273

1.YouCompleteMe插件需要 Vim 7.4.153 以上的版本,如果vim版本过低请先升级:

add-apt-repository ppa:fcwu-tw/ppa
apt-get update
apt-get install vim

2.安装Vundle
Vundle是优秀的vim插件管理工具:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

3.安装YouCompleteMe
将下面的内容拷贝到~/.vimrc中:

set nocompatible              " be iMproved, required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" install YouCompleteMe
Bundle 'Valloric/YouCompleteMe'
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

运行vim 在命令模式下输入如下命令

:PluginInstall

等待安装
注意:YouCompleteMe包比较大,安装过程会持续比较长的时间不要中途中断。
安装完成后

cd ~/.vim/bundle/YouCompleteMe
./install.py --all

等待下载及编译过程(时间较长)
完成安装。