centos7 安裝vim8

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/vim8 -pythoninterp --with-python-config-dir=/usr/lib/python2.7/config -python3interp --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

效果展示

發佈了43 篇原創文章 · 獲贊 11 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章