1.git(用来下载vim和相关插件)

sudo apt-get install git

2,cmake(用来编译clang-llvm)

sudo apt-get install build-essential cmake

3.vim,这里手动编译vim,因为需要python支持,直接apt-get的话会遇到很多麻烦

过程参考 https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
先安装依赖项,注意,Ubuntu 16.04是 `liblua5.1-dev`而不是 `lua5.1-dev`
sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
ibgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
python3-dev ruby-dev lua5.1 liblua5.1-dev libperl-dev git

4.验证安装

vim --version

查找到python,前面有加号即支持python

python3

注意:虽然 vim --version | grep python显示的python前面确实是加号, 但没有针对Ubuntu 16.04更改配置,导致vim支持还是没有安装。

所以个人认为。如果已经有vim的话还是移除它,重新安装

4.1移除:

sudo apt-get remove vim vim-runtime gvim
sudo apt-get remove vim-tiny vim-common vim-gui-common vim-nox

4.2配置:

cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64_linux-gnu \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim81

4.3安装:

cd ~/vim
sudo make install

安装成功后,打开vim,命令模式下输入 :echo has("python") || has("python3"),结果是1就代表成功了。

4.4如果卸载的话相反的,需要保留vim文件夹并且安装checkinstall

sudo apt-get install checkinstall
cd ~/vim
sudo checkinstall

5.安装Vundle(用来管理vim插件)(类似于Python的pip)

5.1.安装:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

5.2.创建并配置.vimrc配置文件

将配置文件添加到你的用户的home文件夹中:

sudo vim ~/vimrc

添加如下内容(大佬配置一):
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'
Plugin 'Valloric/YouCompleteMe'
" 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)
Plugin 'file:///home/gmarik/path/to/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'} " 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
或者添加如下内容(大佬配置二):
"vundle
set nocompatible
filetype off set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin() Plugin 'VundleVim/Vundle.vim'
"git interface
Plugin 'tpope/vim-fugitive'
"filesystem
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim' "html
" isnowfy only compatible with python not python3
"Plugin 'jtratner/vim-flavored-markdown'
Plugin 'suan/vim-instant-markdown'
Plugin 'nelstrom/vim-markdown-preview'
"python sytax checker
Plugin 'nvie/vim-flake8'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'scrooloose/syntastic' "auto-completion stuff
"Plugin 'klen/python-mode'
Plugin 'Valloric/YouCompleteMe'
"Plugin 'klen/rope-vim'
"Plugin 'davidhalter/jedi-vim'
Plugin 'ervandew/supertab'
""code folding
Plugin 'tmhedberg/SimpylFold' "Colors!!!
Plugin 'altercation/vim-colors-solarized'
Plugin 'jnurmine/Zenburn' call vundle#end() filetype plugin indent on " enables filetype detection
let g:SimpylFold_docstring_preview = 1 ""autocomplete
"let g:ycm_autoclose_preview_window_after_completion=1
" YouCompleteMe
set runtimepath+=~/.vim/bundle/YouCompleteMe
let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
let g:ycm_complete_in_comments = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回车即选中当前项
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳转到定义处
"let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配 "custom keys
let mapleader=" "
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"
call togglebg#map("<F5>")
"colorscheme zenburn
"set guifont=Monaco:h14 let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree "I don't like swap files
set noswapfile "turn on numbering
set nu "it would be nice to set tag files by the active virtualenv here
":set tags=~/mytags "tags for ctags and taglist
"omnicomplete
autocmd FileType python set omnifunc=pythoncomplete#Complete "------------Start Python PEP 8 stuff----------------
" Number of spaces that a pre-existing tab is equal to.
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4 "spaces for indents
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
au BufRead,BufNewFile *.py set softtabstop=4 " Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red " Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/ " Wrap text after a certain number of characters
au BufRead,BufNewFile *.py,*.pyw, set textwidth=100 " Use UNIX (\n) line endings.
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix " Set the default file encoding to UTF-8:
set encoding=utf-8 " For full syntax highlighting:
let python_highlight_all=1
syntax on " Keep indentation level from previous line:
autocmd FileType python set autoindent " make backspaces more powerfull
set backspace=indent,eol,start "Folding based on indentation:
autocmd FileType python set foldmethod=indent
"use space to open folds
nnoremap <space> za
"----------Stop python PEP 8 stuff-------------- "js stuff"
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2

5.3.直接运行vim,输入:PluginInstall,等待安装,结束后退出即可。

以后安装插件,直接可以编辑 .vimrc 文件,例如在.vimrc的 call vundle#begin()call vundle#end()之间加上 Plugin 'Valloric/YouCompleteMe',再运行 :PluginInsstall即安装YCM插件,

由于YouCompleteMe有223M左右,所以需要耐心等待,可以时不时用命令 du -s ~/.vim/bundle/YouCompleteMe观察文件夹大小

6.YCM(YouCompleteMe)自动补全

(用Vundle下载慢的话,可以先去官网下载:`git clone https://github.com/Valloric/YouCompleteMe ~/.vim/bundle/YouCompleteMe` )
使用的话有些特殊,需要编译之后才能使用。

6.1. cd ~/.vim/bundle/YouCompleteMe

6.2. 安装支持补全的语言关联: ./install.py

# 这里可以使用install --help查看支持哪些补全

./install.py --clang-completer # 关联C家族的语言; ./install.py # 支持python补全

6.3. 配置文件.ycm_extra_conf.py,包含了补全的系统头文件和源文件出处。(python可以不用配置)

修改flags下的列表即可,在里面添加所需的目录
sudo cp  ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/
sudo vim ~/.ycm_extra_conf.py

改前

改后

如果出现错误:

sudo vim ~/.ycm_extra_conf.py , 然后修改目录:

把.ycm_extra_conf.py放在当前目录配置,是因为YCM是先在当前目录查找再网上走一直递归到找到为止,并且只会加载一次,方便修改。

End

附录博客:

  1. Vundle新老版本的Vundle安装见此文章vundle: vim插件管理安装之错误总结

  2. .vimrc大佬配置二无注释的可以见此文章:Vim配置(python版)

  3. YCM的安装配置见此文章Ubuntu 16.04 64位安装YouCompleteMe

Linux --- vim 安装、支持python3的配置、插件自动补全YCM的安装配置及全过程错误总结的更多相关文章

  1. Vim自动补全神器YouCompleteMe的配置

    简介:YouCompleteMe号称Vim的自动补全神器,该项目在github的地址:YouCompleteMe:以下在10.0.1 build-1379776平台配置完成 插件安装操作: 1.确保V ...

  2. [转] vim配置python自动补全

    vim python自动补全插件:pydiction 可以实现下面python代码的自动补全: 1.简单python关键词补全 2.python 函数补全带括号 3.python 模块补全 4.pyt ...

  3. Python-2.7 配置tab自动补全功能

    作者博文地址:http://www.cnblogs.com/spiritman/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...

  4. Python-2.7 配置 tab 自动补全功能

    作者博文地址:http://www.cnblogs.com/liu-shuai/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...

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

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

  6. 配置Git自动补全功能

    Git装好后,默认是不会有按tab补全命令的功能的.可如下配置: 去git的源码中,找到contrib/completion/git-completion.bash 将git-completion.b ...

  7. Linux下Python模式下【Tab】自动补全

    注:此文为转载他人博客,如有侵权,请联系我删除 1.我们需要一个tab补全的功能脚本  #!/usr/bin/python # python tab file import sys import re ...

  8. vscode中html和vue没有自动补全,需要怎么配置

    先安装HTML Snippets插件 点击 文件-首选项-设置,然后根据以下操作 然后在setting.json中加入以下代码 然后就有提示了

  9. eclipse配置代码自动补全auto-completion

    你如果使用的是JAVA EE的模式,就这样配置: 1. Window>Preferences>Java>Editor>Content Assist>Auto Activa ...

随机推荐

  1. js匹配日期和时间的正则表达式

    自己写比较头疼,copy下来留着以后用 //日期的正则表达式 -]\d{}-([-]|[-])-([-]|[-][-]|[-])$/; var regExp = new RegExp(reg); if ...

  2. 八、Vue中的computed属性

    看了网上很多资料,对vue的computed讲解自己看的都不是很清晰,今天忙里抽闲,和同事们又闲聊起来,对computed这个属性才有了一个稍微比较清晰的认识,下面的文章有一部分是转自: https: ...

  3. Oracle EBS AR 收款取值

    select hr.name, a.autoapply_flag, a.AUTOMATCH_SET_ID, a.LEGAL_ENTITY_ID, a.RECEIPT_NUMBER, a.type, a ...

  4. System.Web.Optimization对脚本和样式表的操作

    这个也是本章重点向描述的部分,首先我们可以使用VS2012RC来新建一个MVC4.0项目,版本可以为4.0或4.5.在Global.asax文件代码中,我们发现已经把过滤器,路由器,以及对样式表和脚本 ...

  5. 山寨"每日故宫"应用的图层遮罩效果

    山寨"每日故宫"应用的图层遮罩效果 最终效果: 应用中的效果: 素材图片: 源码: // // ViewController.m // 每日故宫 // // Created by ...

  6. [翻译] GCDiscreetNotificationView

    GCDiscreetNotificationView GCDiscreetNotificationView is a discreet, non-modal, notification view fo ...

  7. 铁乐学Python_day05-字典dict

    1.[字典dict] Python内置了字典:dict的支持,dict全称dictionary, 在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. 字典和列表直观上 ...

  8. 多个Firefox共存&&彻底关闭自动更新

    安装 0x001 下载好要安装Firefox的版本 可到Firefox官方仓库下载 https://ftp.mozilla.org/pub/firefox/releases/ 我下载的是42和56版 ...

  9. 【连接】Spring事物的传播行为

    http://blog.csdn.net/it_wangxiangpan/article/details/24180085 PROPAGATION_REQUIRED--支持当前事务,如果当前没有事务, ...

  10. 查询包含指定字段的所有表名的SQL脚本

    select [name] from sysobjects where [id] in (select [id] from syscolumns where [name]='ReceiptNbr') ...