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 offset 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:h14let 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

转载于:https://www.cnblogs.com/darksouls/p/9610094.html

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

  1. Shell语法高亮和自动补全设置办法(配置EditPlus)

    近期学习shell,可是没有软件支持高亮显示和补全,写起来费劲很多,现在好了配置EditPlus支持Shell语法高亮和自动补全 第一步.首先下载两个配置文件 我们可以从EditPlus官网的User ...

  2. Sublime Text 中使用OpenSees插件 自动补全及一键运行

    Sublime Text 3中的OpenSees插件配置 Sublime Text 中使用OpenSees插件 自动补全及一键运行 原文连接

  3. Sublime Text 4 下 LaTeXtool 和 Latex-cwl 插件自动补全问题(补充)

    虽然博客Sublime Text 4 下 LaTeXtool 和 Latex-cwl 插件自动补全问题_WingsZeng的博客-CSDN博客_sublime latex 插件 提供了一个解决方法,但 ...

  4. mac vim 安装 YouCompleteMe 插件自动补全

    前言 笔者常用vim进行c/c++/go开发,虽说vim也有自带自动补全(control+n,control+p),不过操作上还是比较麻烦,笔者希望可以实现,输入部分单词可以直接弹出下拉框提示所有可能 ...

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

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

  6. sublime text + LaTex 写作生成PDF | LaTex代码自动补全工具 | MiKTeX安装宏包

    交试验报告老师要求用LaTex.本打算用网页版的,但是overleaf啊什么的不支持中文.没办法只好搞个本地的了. 网上看了一堆乱七八糟的东西教程,装完了还不好使,只好自己写. 这是一个目录 1. L ...

  7. 【shell】linux通过complete命令完成使用tab键自动补全

    一.需求 1.通过shell脚本完成一个linux命令,并在执行时可使用tab键补全命令和参数 2.参数分为一级参数和二级参数,并针对不同的一级参数有二级参数 二.实现方式 通过complete,co ...

  8. 【嗜血GO笔记】如何在goclipse 中配置代码自动补全。

    代码总也不补全,用起来很不爽,但是liteide 的补全却很舒服,看了下 ,发现其实代码提示主要靠的就是gocode.exe这个文件 注意不是godoc.exe哈,有个小伙伴错误设成了godoc.ex ...

  9. android 神气插件 自动补全tabnine

    在一次偶然的机会...搜bug的时候遇到了这个插件..好像支持的ide很多.被称为一款程序员的杀手级插件.但是我主要是做安卓的 也用过了 所以推荐一下 官方网站:https://www.tabnine ...

最新文章

  1. Spring事务管理3----声明式事务管理(1)
  2. 数据蒋堂 | JOIN简化 - 意义总结
  3. bash脚本之for语句if语句以及各种测试语句(2)
  4. 分享9个最棒的代码片段资源网站
  5. NGUI 减少Draw Call
  6. 服务拆分-服务远程调用
  7. 在Spring Boot中使用切面统一处理自定义的异常
  8. 百度OCR文字识别-Android安全校验
  9. 用matlab绘制外部导入数据图像,matlab 外部数据导入方法详解(3)
  10. Flask werkzeug 源码解析
  11. 用java写一个单例类_Java 写一个单例模式(Singleton)出来
  12. 【毕业答辩】毕业设计答辩现场技巧
  13. linux 清空history以及记录原理
  14. [20个项目学会BBC micro:bit编程] 12-蜂鸣器控制
  15. arduino(2560)与步进电机驱动器连线
  16. 记关于DNS协议的一次学习(递归查询与迭代查询)
  17. 国际短信平台怎么找?
  18. http://wang-min-zhao-sina-com.iteye.com/blog/1467204
  19. 某鱼最近卖的很火蓝色版微信去水印小程序源码+接口
  20. 《程序员》2012年4期精彩内容:创业

热门文章

  1. 用python 将PDF中的表格转化为Excel
  2. 群晖 Synology NAS 加密同步至 Dropbox (无Docker版本)
  3. javascript将数字每三位隔开
  4. 安装centos7之后要做的几件事
  5. 求职面试经验分享,提高求职成功率
  6. OPT3001光强传感器驱动实现(STM32F407)
  7. 4-4 能力提升与打造-打造核心竞争力
  8. 基于github和hexo搭建属于自己的博客
  9. 安卓 linux 信令,呼叫信令
  10. 优酷“首月1元”会员引争议:取消续费却被扣24元;马斯克欲在推特建立支付系统,并包含加密货币功能;Deno 1.3发布|极客头条