为VIM安装YouCompleteMe插件

YouCompleteMe

YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vimpython

听说YouCompleteMe是一个强大的自动补全插件,就试着安装一下,体验后确实不错,但安装过程也不是一路顺风的,总结一下过程,但愿下次再用时不要再跳坑喽。git

环境

首先说下我本身的环境,系统是ubuntu16.04 LTS 64位,VIM版本为7.4.1689 -python +python3,VIM安装插件时使用VIM插件管理工具Vundle安装,假设vim已安装vundle插件管理工具(安装vundle也是很简单的,具体步骤请查看vundle官方说明github

安装的前提条件

Ensure that your version of Vim is at least 7.4.143 and that it has support for Python 2 or Python 3 scripting.ubuntu

Inside Vim, type :version. Look at the first two to three lines of output; it should say Vi IMproved X.Y, where X.Y is the major version of >vim. If your version is greater than 7.4, then you're all set. If your version is 7.4 then look below that where it says, Included patches: >1-Z, where Z will be some number. That number needs to be 143 or higher.vim

  • VIM的版本必须是7.4以上,而且patch大于等于143
    VIM的补丁号怎么查看? 使用vim --version, 而后查看第二行,包含补丁:1-Z,其中的Z即为补丁号
  • VIM必须有python2或python3的支持
    在终端中使用vim --version grep python,若是出现的python或python3前面有+号则知足条件,若是都是-号说明不知足条件,须要本身动手编译vim源码或下载7.4以上的版本。
    也能够在启动vim后使用:version,vim命令来查看,还能够使用:echo has('python') || has('python3'),vim命令查看知足条件不。
  • 安装cmake,build-essential,python-dev,python3-dev依赖
    若是本身系统中没有这些包,须要先安装这些依赖,这些依赖是编译YCM的必要条件
    在ubuntu中能够使用sudo apt-get install cmake build-essential python-dev python3-dev来安装,其他系统能够参考YouCompleteMe插件官方说明
    另外若是在执行YouCompleteMe安装以前没有安装这些依赖,那么会出现错误奥,如fatal error:pyconfig.h No such file or directory

安装

安装的步骤仍是很简单的,关键是须要知足前提条件,若是不知足是确定过不去的。。。ide

在~/.vimrc的call vundle#end()以前添加Plugin 'Valloric/YouCompleteMe',而后保存,而后执行:source ~/.vimrcvim命令,而后执行:PluginInstallvim命令,最后就是等待VIM下载YouCompleteMe工具

下载完成后切换到vundle目录下的YouCompleteMe,如本机的
vim-youcompleteme
而后执行./install.py或./install.sh等待安装完成ui

安装完成后新建一个python文件,而后使用vim编辑一下吧,记得使用C-X C-O体验一下全能补全奥。。。插件

po一张最后的效果图
vim-youcompleteme2code

相关文章
相关标签/搜索