Vim 安装 YouCompleteMe
Vim 下的自动补全,最好的工具莫过于 YouCompleteMe,官方文档在这里 http://valloric.github.io/YouCompleteMe/
安装稍显复杂,以下记录我的过程。
1. 安装 Vundle
(这里顺带就把 YouCompleteMe 下载了)
Vundle 是 Vim 下的一个插件管理器,如果之前你配置 Vim 是手动放置 xxx.vim 配置文件到相应目录,那么现在你要安装 Vundle, 因为 YouCompleteMe 是基于 Vundle 安装的,
Vundle 的 github 地址: https://github.com/VundleVim/Vundle.vim
- git 克隆插件 $ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- 添加如下内容到 ~/.vimrc 文件最前面,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For Vundle Start
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 'VundleVim/Vundle.vim'
" Install YouCompleteMe
Plugin 'Valloric/YouCompleteMe' " 注意,这就是要安装的插件 YouCompleteMe
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For Vundle End
保存关闭。
- 启动 Vim,执行命令 :PluginInstall 将出现如下安装画面,( YouCompleteMe 插件较大,请耐心等待)

2. 编译 YouCompleteMe
- 安装相关工具
$ sudo apt-get install build-essential cmake
- 安装相关 Python 库
$ sudo apt-get install python-dev python3-dev
- 编译 (为支持 C,C++,Python 智能补全,添加选项 --clang-completer)
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
注: 为支持其他语言,比如 Javascript,Go 等,要首先安装相应的工具,具体参见官方文档。
3. 设置 .vimrc
“ 配置默认的 .ycm_extra_conf.py 路径
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py'
注:当有新库加入时,需要更新此文件,例如,我要支持 boost 的补全,则要加入 boost 头文件路径 /usr/local/boost_1_67_0,加到 flags 的最后即可,
flags = [ ... # for boost complete
'-isystem',
'/usr/local/boost_1_67_0'
]
4. 使用中的问题
- 补全功能可用,但是会有恼人的信息,

我当前安装的 gVim 版本是 7.4.52, 根据 YouCompleteMe 官网的建议,升级到 7.4.314 以上可解决这个问题,于是,
# add-apt-repository ppa:pi-rho/dev
# apt-get update
# apt-get install vim-gnome (重装即可升级)
升级后,问题解决。
注: 补全时,当弹出 tip 窗口,按 Tab 来 cycle 可选项。
另, Centos 升级 gvim 到 8.x 版本见:https://www.cnblogs.com/gaowengang/p/10546815.html
对于 Ubuntu 18.04 的 workaround 方法
因为我之前一直用 Ubuntu 14.04 和 CentOS 7,这两个操作系统默认的 gcc 版本是 4.8,我在这两个系统下完成了对 gvim 的各种配置(包括 YouCompleteMe 的配置),并且各项功能都调好了。
因项目需要,在升级系统到 Ubuntu 18.04 后,为方便起见,我把旧系统的 .vimrc 和 .vim 拷贝到新系统的 home 目录下, 并调整 YouCompleteMe 配置文件的内容,使其指向新系统的 c++ 头文件目录,但是却不能实现 c++ 的自动补全。目前怀疑和 Ubuntu 18.04 的 gcc 和 g++ 版本有关,新系统默认的版本是 7.4。
workaround 方法是:安装 gcc 4.8 ( $ sudo apt-get install gcc-4.8 ) 和 g++ 4.8 ( $ sudo apt-get install g++-4.8 ),并调整 YouCompleteMe 配置文件,使其指向 c++ 4.8 的头文件目录。
完。
Vim 安装 YouCompleteMe的更多相关文章
- vim安装YouCompleteMe 插件
要安装YouCompleteMe ,vim须支持python.看是否支持,可以在vim中:version 查看, 如果python前有+号,就是支持,减号就是不支持. 如果不支持,需要以编译安装方式重 ...
- 给vim安装YouCompleteMe
要安装YouCompleteMe ,vim须支持python.看是否支持,可以在vim中:version 查看, 如果python前有+号,就是支持,减号就是不支持. 如果不支持,需要以编译安装方式重 ...
- UBuntu14.04 --vim安装YouCompleteMe插件
说明 我电脑的系统参数(用 uname -a命令查看)如下: Linux avyn-Lenovo --generic #-Ubuntu SMP Tue Mar :: UTC i686 i686 i68 ...
- Vim+Vundle+YouCompleteMe 安装
这段时间在Centos 7上开发c++程序,想为vim安装YouCompleteMe插件,参照几个博客无果,果断上官网找解决方案.功夫不负苦心人,终于搞定. 学习东西还是要多上官网. 下面送上本次的收 ...
- vim 安装
Ubuntu 16.04 下 Vim安装及配置 默认已经安装了VIM-tiny linuxidc@linuxidc:~$ locate vi | grep 'vi$' |xargs ls -al lr ...
- Ubuntu16.04安装vim插件YouCompleteMe
原文 1 下载 git clone --recursive git://github.com/Valloric/YouCompleteMe 如果执行该命令没报错, 就ok了. 但是中途有可能会断掉, ...
- 解决安装YouCompleteMe与Vim版本不兼容问题
用vim 7.4.4版本装YouCompleMe的时候提示这样的信息: YouCompleteMe unavailable: requires Vim 7.4.1578+.明明版本比它要求的还高,居然 ...
- Vim中YouCompleteMe插件安装
背景 YouCompleteMe需要使用GCC进行编译,然而Centos 6.7默认的GCC版本太低,所以需要使用devtools-2,用来安装多个版本GCC手动编译安装GCC的坑简直不要太多(类似于 ...
- 【转】ubuntu 12.04 下 Vim 插件 YouCompleteMe 的安装
原文网址:http://www.cnblogs.com/jostree/p/4137402.html 作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree ...
随机推荐
- 移动前端—H5实现图片先压缩再上传
在做移动端图片上传的时候,用户传的都是手机本地图片,而本地图片一般都相对比较大,拿iphone6来说,平时拍很多图片都是一两M的,如果直接这样上传,那图片就太大了,如果用户用的是移动流量,完全把图片上 ...
- 51NOD 1185 威佐夫游戏 V2(威佐夫博弈)
1185 威佐夫游戏 V2 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 有2堆石子.A B两个人轮流拿,A先拿.每次可以从一堆中取任意个或从2堆中取 ...
- Tars http服务
http服务 发布到平台后可以直接使用 http 请求来调用,注意发布服务时选择 非 tars 协议! 1,创建一个 springboot 项目,并在启动类添加 @EnableTarsServer 注 ...
- 显示Linux进程打开了哪些文件? 用lsof命令
1.lsof abc.txt --> 显示开启文件 abc.txt的进程. 2.lsof -c abc ---> 显示abc进程现在打开的文件. 3.lsof -c -p 1234 -- ...
- Android 布局巧用之include、merge、ViewStub
原文链接:https://mp.weixin.qq.com/s/bTA2gztUzqvqER2rz56RRQ 相信大家经常听到include.merge.ViewStub这样的标签,官方也提到这三种布 ...
- ReactNative编写规范
<一> React 代码规范 文件与组件命名 扩展名: 使用.js作为js文件的扩展名.如果同一个文件夹下有同名而不同作用的js文件,则通过中缀(小写)进一步区分,例如:HomePage ...
- Django 系统日志logging
Django使用Python内建的logging模块去建造自己的系统日志的,如果你想详细了解这个模块的话,请自己去看python的说明文档,这里仅仅介绍Django中的日志系统. 日志配置包括四个部分 ...
- JavaScript中,JSON格式的字符串与JSON格式的对象相互转化
前言:JSON是一个独立于任何语言的数据格式,因此,严格来说,没有“JSON对象”和“JSON字符串”这个说法(然而”菜鸟教程“和”W3school“使用了“JSON对象”和“JSON字符串”这个说法 ...
- ORACLE如何找到引起账号锁定的IP的一点思考与总结
在ORACLE数据库中,如果没有修改过FAILED_LOGIN_ATTEMPTS的话,默认10次尝试失败后就会锁住用户.此时再登录数据库,就会遇到ORA-28000: the account is l ...
- weblogic报错----Received exception while creating connection for pool "TDMSKD": The Network Adapter could not establish the connection
<2017-8-16 上午08时58分37秒 CST> <Info> <WebLogicServer> <BEA-000377> <Startin ...