1.下载安装

项目首页:https://github.com/vim/vim

git clone https://github.com/vim/vim.git
cd vim/src
./configure --prefix=/usr/local/vim-8.0
make && make install

需要python支持的configure配置,python2和python3最好不要共存:

./configure --prefix=/usr/local/vim-8.0 \
 --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

centos环境下python-config的地址为/usr/lib64/python2.6/config,需要有python环境:

yum install python-devel

2. 添加软连接

# 备份之前的软链接
mv /usr/bin/vim /usr/bin/vim7
mv /usr/bin/vi /usr/bin/vi7
# 添加新链接
ln -s /usr/local/vim-8.0 /usr/local/vim
ln -s /usr/local/vim/bin/vim /usr/bin/vi
ln -s /usr/local/vim/bin/vim /usr/bin/vim
# 添加环境变量
echo "export VIM=/usr/local/vim" >> /etc/profile
echo "export VIMRUNTIME=\$VIM/share/vim/vim80" >> /etc/profile
echo "export PATH=\$PATH:\$VIM/bin" >> /etc/profile

3.检查是否安装成功

> vi --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 19 2018 11:27:16)
Included patches: 1-1616
Compiled by ma@vm
Huge version without GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vertsplit
-clipboard         +jumplist          +persistent_undo   +virtualedit
+cmdline_compl     +keymap            +postscript        +visual
+cmdline_hist      +lambda            +printer           +visualextra
+cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           +python            +vreplace   
+conceal           +linebreak         -python3           +wildignore
+cryptv            +lispindent        +quickfix          +wildmenu
+cscope            +listcmds          +reltime           +windows
+cursorbind        +localmap          +rightleft         +writebackup
+cursorshape       -lua               -ruby              -X11
+dialog_con        +menu              +scrollbind        -xfontset
+diff              +mksession         +signs             -xim
+digraphs          +modify_fname      +smartindent       -xpm
-dnd               +mouse             +startuptime       -xsmp
-ebcdic            -mouseshape        +statusline        -xterm_clipboard
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save
+eval              -mouse_gpm         +syntax            
+ex_extra          -mouse_jsbterm     +tag_binary        
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/vim-8.0/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lnsl   -ldl     -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -lpython3.5m

上面的+python表示已添加python2支持。

另外一种查看支持python的方法:在vim编辑器中输入:echo has(''python'') || has(''python3''),返回1就表示支持。

4.安装vundle插件管理

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

~/.vimrc中添加插件支持:

set nocompatible
filetype off

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin ''VundleVim/Vundle.vim''
call vundle#end()

filetype plugin indent on

打开vim,输入PluginInstall能进入以下界面表示安装成功:

5. .vimrc配置

.vimrc配置

最后修改:2018 年 03 月 19 日
喜欢就给我点赞吧