centos7 中使用yum安装的vim是7.4的,现在为了体验更多的功能,我们选择vim8
下载
wget ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2
tar -jxf vim-8.0.tar.bz2
cd vim80
安装
make clean
./configure --with-features=huge --prefix=/usr/local/vim --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config --enable-python3interp=yes --with-python3-config-dir=/usr/local/python3/config
make
make install
–with-features=huge:支持最大特性
–enable-rubyinterp:打开对ruby编写的插件的支持
–enable-pythoninterp:打开对python编写的插件的支持
–enable-python3interp:打开对python3编写的插件的支持
–enable-luainterp:打开对lua编写的插件的支持
–enable-perlinterp:打开对perl编写的插件的支持
–enable-multibyte:打开多字节支持,可以在Vim中输入中文
–enable-cscope:打开对cscope的支持
–with-python-config-dir=/usr/lib/python2.7/config 指定python 路径(默认系统python2的路径)
–with-python-config-dir=/usr/local/python3/config 指定python3路径(自己安装的python3的路径)
–prefix=/usr/local/vim:指定将要安装到的路径(自行创建)
替换
mv /usr/bin/vim /usr/bin/vim7
ln -s /usr/local/vim8/bin/vim /usr/bin/vim
配置
vim ~/.vimrc
set encoding=utf-8
set fileencodings=usc-bom,utf-8,cp936
set termencoding=utf-8
syntax on
set cursorline cursorcolumn
set incsearch
set ignorecase
set smartcase
set history=10000
set nofoldenable
set confirm
set backspace=indent,eol,start
set t_Co=256
set report=0
set nowrap
set scrolloff=5
set number
set ruler
set showmatch
set showcmd
set title
set laststatus=2
set matchtime=2
set matchpairs+=<:>
set autoindent
set smartindent
set tabstop=4
set softtabstop=4
set smarttab
set textwidth=120
set colorcolumn=+1
set autoread
set autowrite
插件
安装vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
插件列表
vim ~/.vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'mattn/calendar-vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'suan/vim-instant-markdown'
"Plugin 'sirver/ultisnips'
Plugin 'pboettch/vim-cmake-syntax'
Plugin 'Valloric/YoucompleteMe'
Plugin 'kien/ctrlp.vim'
Plugin 'jiangmiao/auto-pairs'
Plugin 'EasyGrep'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/ListToggle'
Plugin 'bling/vim-airline'
Plugin 'maralla/completor.vim'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'nvie/vim-flake8'
Plugin 'Lokaltog/vim-powerline'
Plugin 'Yggdroot/indentLine'
Plugin 'lervag/vimtex'
Plugin 'tpope/vim-fugitive'
Plugin 'EditPlus'
Plugin 'cst'
Plugin 'Xdebug'
Plugin 'PyChimp'
Plugin 'snipMate'
call vundle#end()
filetype plugin indent on
" :PluginList 插件列表
" :PluginInstall 安装插件 末尾加!表示更新插件 等同于:PluginUpdate
" :PluginSearch 查找插件
" :PluginClean 删除插件
" :h vundle 查看更多vundle相关指令
保存.vimrc后,重新进入vim,执行:PluginInstall进行插件安装
设置YouCompleteMe
let g:ycm_min_num_of_chars_for_completion=3
let g:ycm_python_binary_path='python'
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_auto_trigger=1
if has('python3')
let g:loaded_youcompleteme = 1 " 判断如果是python3的话,就禁用ycmd。
let g:jedi#force_py_version = 3
let g:pymode_python = 'python3'
endif
最终版.vimrc
set encoding=utf-8
set fileencodings=usc-bom,utf-8,cp936
set termencoding=utf-8
syntax on
set cursorline cursorcolumn
set incsearch
set ignorecase
set smartcase
set history=10000
set nofoldenable
set confirm
set backspace=indent,eol,start
set t_Co=256
set report=0
set nowrap
set scrolloff=5
set number
set ruler
set showmatch
set showcmd
set title
set laststatus=2
set matchtime=2
set matchpairs+=<:>
set autoindent
set smartindent
set tabstop=4
set softtabstop=4
set smarttab
set textwidth=120
set colorcolumn=+1
set autoread
set autowrite
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'mattn/calendar-vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'suan/vim-instant-markdown'
"Plugin 'sirver/ultisnips'
Plugin 'pboettch/vim-cmake-syntax'
Plugin 'Valloric/YoucompleteMe'
Plugin 'kien/ctrlp.vim'
Plugin 'jiangmiao/auto-pairs'
Plugin 'EasyGrep'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/ListToggle'
Plugin 'bling/vim-airline'
Plugin 'maralla/completor.vim'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'nvie/vim-flake8'
Plugin 'Lokaltog/vim-powerline'
Plugin 'Yggdroot/indentLine'
Plugin 'lervag/vimtex'
Plugin 'tpope/vim-fugitive'
Plugin 'EditPlus'
Plugin 'cst'
Plugin 'Xdebug'
Plugin 'PyChimp'
Plugin 'snipMate'
call vundle#end()
filetype plugin indent on
" :PluginList 插件列表
" :PluginInstall 安装插件 末尾加!表示更新插件 等同于:PluginUpdate
" :PluginSearch 查找插件
" :PluginClean 删除插件
" :h vundle 查看更多vundle相关指令
let g:ycm_min_num_of_chars_for_completion=3
let g:ycm_python_binary_path='python'
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_auto_trigger=1
if has('python3')
let g:loaded_youcompleteme = 1 " 判断如果是python3的话,就禁用ycmd。
let g:jedi#force_py_version = 3
let g:pymode_python = 'python3'
endif
效果展示