安装方法:
- 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
根目录下,通过显示隐藏文件查看以及后续编辑操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- Step-7:在
.vimrc
的begin/end
之间添加PluginInstall 'Valloric/YouCompleteMe'
如图所示 - Step-8:
ctrl+alt+T
打开terminal
输入vim
激活打开vim
- Step-9:键盘输入
:PluginInstall
就可以开始安装YouCompleteMe
及.vimrc
中的其他插件(网络原因,速度巨慢!)解决方法如下:
先下载再配置安装:
1 2 3 4 5 |
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 1234 |
- 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
最后添加下面第二行,并保存
1 2 3 4 |
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'123 |
- Step-14:利用
Vim
创建或编辑.py
文件 - Step-15:
Tab
键可自动显示补齐模块内容

- Step-16:虚拟环境下记得激活虚拟环境
source activate envs_name
才可运行程序

PS:.vimrc文件设置截图

