YouCompleteMe安装教程

2025-11-02 05:26:28

1、安装Vundle插件管理工具

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

在vim的配置文件vimrc里面添加如下内容(vimrc文件位置,命令模式下:echo $VIM)

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')

" let Vundle manage Vundle, required

Plugin 'gmarik/Vundle.vim'

Plugin 'Valloric/YouCompleteMe'

" 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

2、注意,需要注释掉vimrc文件中的 runtime!debian.vim

即在此行前加"号

Vundle安装完成后就可以开始安装YouCompleteMe了,配置已经在上述的文件中写好

打开vim,命令行模式下输入 :PluginInstall

然后就可以看到插件正在安装,由于需要下载的文件比较多(主要是下载的比较慢,普通下载速度在10kb左右),需要的时间可能会有些长,一定要耐心等待,比如作者本人就等了三个小时才提示安装完成

3、安装完成YouCompleteMe以后,需要配置方可真正发挥作用

在 vimrc文件中添加如下内容:

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

然后重新打开vim即可

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢