最近刚装了新系统CentOS7,想要把编码环境配置一下,使用Vim编写程序少不了使用自动补全插件,我以前用的是neocomplcache+code_complete+omnicppcomplete。但在网上搜索时,看到了YouCompleteMe,说YCM更好用一些。个人也喜欢新鲜事物,故决定安装YCM。但安装过程遇到了不少坑,网上的教程有不同的安装方法,基本都试遍了。最终在倒腾了一下午的情况下终于弄好了,现在把可行的安装配置方法贴出来,以供需要的人参考。

YouCompleteMe:一个随键而全的、支持模糊搜索的、高速补全的插件。YCM 由 google 公司搜索项目组的软件工程师 Strahinja Val Markovic 所开发,YCM 后端调用 libclang(以获取AST,当然还有其他语言的语义分析库)、前端由 C++ 开发(以提升补全效 率)、外层由 python 封装(以成为 vim 插件),它可能是我见过安装最复杂的 vim 插件了。

要安装YouCompleteMe ,vim须支持python。看是否支持,可以在vim中:version 查看, 如果python前有+号,就是支持,减号就是不支持。

如果不支持,需要以编译安装方式重新安装vim。编译配置选项:

./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset

一、安装vundle插件

步骤一:

[zhupengfei@localhost ~]$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle^C

步骤二: 在.vimrc中配置

[zhupengfei@localhost ~]$ vim .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 进行自动安装。

进程如下,+号表示已经安装,>表示正在安装。

[zhupengfei@localhost ~]$ vim
:BundleInstall

安装时有个错误,这是正常的,因为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!

二、安装配置YouCompleteMe

步骤四: 然后到.vim/bundle/YouCompleteMe 下执行命令:

./install.sh --clang-completer

参数是为了支持c/c++的补全

[zhupengfei@localhost YouCompleteMe]$ ./install.sh --clang-complete

然后可能还会出现报错:

Some folders in /home/sky-tm/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party are empty; you probably forgot to run:    git submodule update --init --recursive

若出现此错误,则按照提示来,继续输入命令:

git submodule update --init --recursive

[zhupengfei@localhost YouCompleteMe]$git submodule update --init --recursive

等此命令更新完成后,再此执行命令:

./install.sh --clang-completer

[zhupengfei@localhost YouCompleteMe]$ ./install.sh --clang-complete

安装完成后,进行一些简单的配置就可以使用了。

YouCompleteMe进行补全时需要查找一个 ycm_global_ycm_extra_conf文件。可以每次在工作目录中放置这个文件,也可以设置全局。全局设置要在.vimrc中添加一行即可。

注:.ycm_extra_conf.py 是个隐藏文件,路径在~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py

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

关于.vimrc的配置就不贴了,网上有很多,可以根据个人的喜好进行配置。

CentOS7 Vim自动补全插件----YouCompleteMe安装与配置的更多相关文章

  1. 【转】Vim自动补全插件----YouCompleteMe安装与配置

    原文网址:http://www.cnblogs.com/zhongcq/p/3630047.html 使用Vim编写程序少不了使用自动补全插件,在Linux下有没有类似VS中的Visual Assis ...

  2. Vim自动补全插件----YouCompleteMe安装与配置

    Vim自动补全插件----YouCompleteMe安装与配置 使用Vim编写程序少不了使用自动补全插件,在Linux下有没有类似VS中的Visual Assist X这么方便快捷的补全插件呢?以前用 ...

  3. CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置

    备注:现在对于 YouCompleteMe 的安装应采用更为简单的方法,即利用 Vundle 来安装这个插件.具体方法可见: Vundle 主页 YouCompleteMe 主页 而 .vimrc 的 ...

  4. 如何安装vim自动补全插件YouCompleteMe(YCM)

    Vim是全平台上一个高度可拓展的编辑器.它本身只是一个简陋的编辑器,但是因为有各种插件而变得强大.使用Vim编写代码就不免遇到代码补全的问题.常用的代码补全插件有两个:日本人shougo写的neoco ...

  5. vim自动补全插件YouCompleteMe

    前言 Valloric/YouCompleteMe可以说是vim安装最复杂的插件之一,但是一旦装好,却又是非常好用的.YouCompleteMe简称ycm 在安装折腾的过程中,我再一次的体会到,除了官 ...

  6. vim自动补全插件YouCompleteMe的安装及配置

    原文地址: http://blog.csdn.net/shixuehancheng/article/details/46289811

  7. VIM 代码自动补全, YouCompleteMe安装及配置

    效果 下载 使用Vundle安装 YCM 1. 安装Vundle window用户安装vundle参考这里:Windows下 vundle的安装和使用 2.

  8. Vim自动补全神器–YouCompleteMe

    YouCompleteMe的特别之处 基于语义补全 总所周知,Vim是一款文本编辑器.也就是说,其最基础的工作就是编辑文本,而不管该文本的内容是什么.在Vim被程序员所使用后,其慢慢的被肩负了与IDE ...

  9. VIM自动补全插件 - YouCompleteMe--"大神级vim补全插件"

    VIM自动补全插件 - YouCompleteMe 序言 vim 之所以被称为编辑器之神多半归功于其丰富的可DIY的灵活插件功能,( 例如vim下的这款神级般的代码补全插件YouCompleteMe) ...

随机推荐

  1. 跟我学CMD实战系列之二 ——数据压缩备份

    需求:每天下班时,将本地硬盘上的projects目录压缩为rar文件,文件名中必须含有当天日期信息,例如projects_20070902.rar. 分析:1. 压缩可以调用WinRAR的命令行版本r ...

  2. 在Windows中安装MinGW-w64(有图,一步一步)

    在Windows中安装MinGW-w64 发表回复 如需配合Sublime Text 3编译C程序, 请参考本站文章: 使用Sublime Text 3与MinGW-w64编译C语言程序 MinGW, ...

  3. 如何使用egit将本地代码提交到托管平台

    本文将讲述如何使用eclipse中的egit插件,将代码提交到git托管平台. Eclipse版本:4.7.0 自带egit插件 云端托管平台:华为软件开发云 1.本地git工具安装&环境配置 ...

  4. cordova使用cordova-plugin-baidumaplocation插件获取定位

    原文:cordova使用cordova-plugin-baidumaplocation插件获取定位 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/m ...

  5. c语言学习笔记(14)——算法

    链表 算法: 1.通俗定义: 解题的方法和步骤 2.狭义定义: 对存储数据的操作 对不同的存储结构,要完成某一个功能所执行的操作是不一样的 比如:要输出数组中所有的元素和输出链表中所有元素的操作是不一 ...

  6. Netty:一种非易失堵塞client/server相框

    Netty:一种非易失堵塞client/server相框 作者:chszs.转载需注明.博客主页:http://blog.csdn.net/chszs Netty是一个异步事件驱动的网络应用框架,为J ...

  7. WPF MVVM系列文章

    网上搜到了MSDN Magazine上Laurent Bugnion的系列文章. 以下为关于WPF的优秀实践,很有必要阅读. 很吸引人的标题有: IOC Containers and MVVM Mes ...

  8. (转)移动端自定义返回上一页的方法:history

    在实际的应用中,我们常常需要实现在移动app和浏览器中点击返回.后退.上一页等按钮实现自己的关闭页面.调整到指定页面或执行一些其它操作的需求. 那在代码中怎样监听当点击微信.支付宝.百度糯米.百度钱包 ...

  9. 安装Eclipse完PyDev插件中没有出现

    假设你是在Window7在环境搭建.请确保您使用以管理员身份运行Eclipse. PyDev插件安装后没有显示是由于PyDev的执行须要Java7,能够通过升级JDK的版本号来完毕,而且配置环境变量( ...

  10. Angular路由守卫 canActivate

    作用 canActivate 控制是否允许进入路由. canActivateChild 等同 canActivate,只不过针对是所有子路由. 关键代码 创建路由守卫 import { Injecta ...