版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/qq_33039859/article/details/81490382
参考博客
参考1-让vim支持python3的自动补全【促使我利用YouCompleteMe配置Anaconda环境】
参考2-Ubuntu16.04下配置YouCompleteMe【常规安装套路】
参考3-Ubuntu16.04 为vim安装YouCompleteMe插件【主要参考这篇文章成功安装YCM】
参考4-ycm_core loading issues on Ubuntu 16.04 #2136【在这里找到了Anaconda环境无法识别的原因】
参考5-YouCompleteMe does not work with Anaconda Python #1241【另外一种配置Vim+Anaconda的方法(未实验)】
参考6-Ubuntu16.04 为vim安装YouCompleteMe插件【转载的参考3,内容一模一样】
参考7-一步一步带你安装史上最难安装的 vim 插件 —— YouCompleteMe【评论很多的一篇博客】
安装方法:
- Step-1:安装vim:
sudo apt-get install vim-gtk
- Step-2:查看vim对python的支持:
vim --version | grep python
- Step-3:安装CMake:
sudo apt-get install build-essential cmake
- Step-4:安装python-dev:
sudo apt-get install python-dev python3-dev
- Step-5:安装YouCompleMe:
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- Step-6:复制YCM官网
vimrc
文件到/home
根目录下,通过显示隐藏文件查看以及后续编辑操作
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'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" 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/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" cs Plugin
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
- Step-7:在
.vimrc
的begin/end
之间添加PluginInstall 'Valloric/YouCompleteMe'
如图所示 - Step-8:
ctrl+alt+T
打开terminal
输入vim
激活打开vim
- Step-9:键盘输入
:PluginInstall
就可以开始安装YouCompleteMe
及.vimrc
中的其他插件(网络原因,速度巨慢!)解决方法如下:
先下载再配置安装:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive
- Step-10:切换到
YouCompleteMe目录
- Step-11:最重要的一步:利用Anaconda中的python3执行
python3 ./install.py
文件
如下图所示,默认状态下的python3
为Anaconda的python3
- Step-12:根据需要参考
参考3
,进行相关配置(感觉非必要) - Step-13-1:如果需要
vim
自动补齐Anaconda
自带环境下的site-packages
则在.vimrc
最后添加下面第一行,并保存 - Step-13-2:如果需要
vim
自动补齐Anaconda
虚拟环境envs
下的site-packages
则在.vimrc
最后添加下面第二行,并保存
let g:ycm_python_binary_path = '/home/brucelau/anaconda3/bin/python3.6'
let g:ycm_python_binary_path = '/home/brucelau/anaconda3/envs/fcn/bin/python3.5'
- Step-14:利用
Vim
创建或编辑.py
文件 - Step-15:
Tab
键可自动显示补齐模块内容
- Step-16:虚拟环境下记得激活虚拟环境
source activate envs_name
才可运行程序
PS:.vimrc文件设置截图