Welcome 微信登录

首页 / 操作系统 / Linux / Vim安装YouCompleteMe 插件

要安装YouCompleteMe ,Vim须支持Python。看是否支持,可以在Vim中:version 查看, 如果Python前有+号,就是支持,减号就是不支持。如果不支持,需要以编译安装方式重新安装Vim。编译配置选项:./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset在我的机器上装有python2.7.5 和 python3.3, 但加了enable-python3interp参数依然没有支持py3,不知何故,先不管,YouCompleteMe 只要求有py2.6以上。安装vundle插件git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle在.vimrc中配置set nocompatible              " be iMproved, required
filetype off                  " required" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install plugins
"let path = "~/some/path/here"
"call vundle#rc(path)" let Vundle manage Vundle, required
Plugin "gmarik/vundle"" The following are examples of different formats supported.
" Keep Plugin commands between here and filetype plugin indent on.
" scripts on GitHub repos
Plugin "tpope/vim-fugitive"
Plugin "Lokaltog/vim-easymotion"
Plugin "tpope/vim-rails.git"
" 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/"}
" scripts from http://vim-scripts.org/vim/scripts.html
Plugin "L9"
Plugin "FuzzyFinder"
" scripts not 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"
" ...filetype plugin indent on   " required
Bundle "Valloric/YouCompleteMe"保存退出,打开vim,输入 :BundleInstall 进行自动安装进程如下,+号表示已经安装,>表示正在安装。. Plugin "gmarik/vundle" |~
+ Plugin "tpope/vim-fugitive" |~
+ Plugin "Lokaltog/vim-easymotion" |~
+ Plugin "tpope/vim-rails.git" |~
+ Plugin "rstacruz/sparkup" |~
+ Plugin "L9" |~
+ Plugin "FuzzyFinder" |~
> Plugin "git://git.wincent.com/command-|~
t.git" |~
Plugin "file:///home/gmarik/path/to/pl|~
ugin" |~
Plugin "Valloric/YouCompleteMe" |~
Helptags结束时有个错误,这是正常的,因为ycm需要手工编译出库文件Done! With errors; press l to view log
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need
 to compile YCM before using it. Read the docs!到 .vim/bundle/YouCompleteMe 下跑 ./install.sh --clang-completer参数是为了支持c/c++ 的补全。安装完成后进行一些简单的配置就可以使用。YouCompleteMe 的补全配置文件在/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py,这是个隐藏文件。默认会使用这个文件,也可以把这个文件copy到工程的根目录中作修改,打开工程文件时会优先使用当前目录下的配置文件。如果找不到,会根据配置中的ycm_global_ycm_extra_conf 进行查找。在.vimrc 中添加let mapleader = ","  " 这个leader就映射为逗号“,”let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py" “配置默认的ycm_extra_conf.py
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> “按,jd 会跳转到定义
let g:ycm_confirm_extra_conf=0    “打开vim时不再询问是否加载ycm_extra_conf.py配置
let g:ycm_collect_identifiers_from_tag_files = 1 "使用ctags生成的tags文件更多Vim相关教程见以下内容:把VIM打造成一个简单实用的IDE http://www.linuxidc.com/Linux/2011-06/37032.htmVim学习指南 http://www.linuxidc.com/Linux/2013-08/89096.htm快速学会 Vi编辑器 http://www.linuxidc.com/Linux/2013-08/88586.htm强大的Vim 编辑器 http://www.linuxidc.com/Linux/2013-07/87544.htm在CentOS 6.2上搭建Vim开发环境 http://www.linuxidc.com/Linux/2013-07/87363.htmCentOS 5.4 安装高亮Vim编辑工具 http://www.linuxidc.com/Linux/2013-06/86508.htmVim技巧分享:C语言设置 http://www.linuxidc.com/Linux/2012-12/77124.htmUbuntu中设置Vim的行号 http://www.linuxidc.com/Linux/2012-12/75485.htmVim编辑器使用基础教程 http://www.linuxidc.com/Linux/2013-05/84031.htm本文永久更新链接地址