安装必要的库 1 yum install gcc make ncurses ncurses-devel -y
安装常用编程语言的库 1 yum install ctags git tcl-devel ruby ruby-devel lua lua-devel luajit luajit-devel python python-devel perl perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder perl-ExtUtils-Embed -y
删除现有的 Vim 安装 1 2 3 yum list installed | grep -i vim sudo yum remove vim-enhanced vim-common vim-filesystem
删除vim配置文件
下载最新的源码 1 2 3 sudo git clone https://github.com/vim/vim.git 或者自己去网站上下载一个8.2版本的vim包,解压进入其中
修改vim的文件 1 2 3 4 5 cd vim echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h echo '#define SYS_GVIMRC_FILE "/etc/gvimrc"' >> src/feature.h
这两个参数是修改这个的
1 2 3 4 5 6 7 8 9 vim --version *** system vimrc file: "/etc/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/share/vim" "
配置 Vim 1 2 ./configure --with-features=huge --enable-multibyte --enable-python3interp --enable-rubyinterp --enable-perlinterp --enable-luainterp --enable-gui=gtk3 --enable-cscope --with-tlib=ncursesw --prefix=/usr
列举一些 ./configure 后面的配置选项 需要啥自己添加
1 2 3 4 5 6 7 8 9 10 11 12 --with-features=huge:支持最大特性 --enable-multibyte:打开多字节支持,可以在Vim中输入中文 --enable-rubyinterp:打开对ruby编写的插件的支持 --enable-pythoninterp:打开对python编写的插件的支持 --with-python-config-dir=/usr/lib64/python2.7/config 指定python路径(此处是腾讯云CentOS7.4的python2路径) --enable-python3interp:打开对python3编写的插件的支持 --with-python-config-dir=/usr/local/python3.7/lib/python3.7/config-3.7m-x86_64-linux-gnu 指定python3路径(此处是我指定位置安装python3后的路径,CentOS编译安装python3.7.0) --enable-perlinterp:打开对perl编写的插件的支持 --enable-luainterp:打开对lua编写的插件的支持 --enable-gui=gtk2:gtk2支持,也可以使用gnome,表示生成gvim --enable-cscope:打开对cscope的支持 --prefix=/usr/local/vim:指定将要安装到的路径(自行创建)
编译vim
安装vim
查看vim版本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 vim -version VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 21 2022 16:07:27) Included patches: 1-4801 Compiled by root@Fish Huge version without GUI. Features included (+) or not (-): +acl +file_in_path +mouse_urxvt -tag_any_white +arabic +find_in_path +mouse_xterm -tcl +autocmd +float +multi_byte +termguicolors +autochdir +folding +multi_lang +terminal -autoservername -footer -mzscheme +terminfo -balloon_eval +fork() +netbeans_intg +termresponse +balloon_eval_term +gettext +num64 +textobjects -browse -hangul_input +packages +textprop ++builtin_terms +iconv +path_extra +timers +byte_offset +insert_expand +perl +title +channel +ipv6 +persistent_undo -toolbar +cindent +job +popupwin +user_commands -clientserver +jumplist +postscript +vartabs -clipboard +keymap +printer +vertsplit +cmdline_compl +lambda +profile +vim9script +cmdline_hist +langmap -python +viminfo +cmdline_info +libcall +python3 +virtualedit +comments +linebreak +quickfix +visual +conceal +lispindent +reltime +visualextra +cryptv +listcmds +rightleft +vreplace +cscope +localmap +ruby +wildignore +cursorbind +lua +scrollbind +wildmenu +cursorshape +menu +signs +windows +dialog_con +mksession +smartindent +writebackup +diff +modify_fname -sodium -X11 +digraphs +mouse -sound -xfontset -dnd -mouseshape +spell -xim -ebcdic +mouse_dec +startuptime -xpm +emacs_tags -mouse_gpm +statusline -xsmp +eval -mouse_jsbterm -sun_workshop -xterm_clipboard +ex_extra +mouse_netterm +syntax -xterm_save +extra_search +mouse_sgr +tag_binary -farsi -mouse_sysmouse -tag_old_static system vimrc file: "/etc/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/share/vim" Compilation: gcc -std=gnu99 -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -std=gnu99 -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo -ldl -L/usr/lib -llua -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE -fstack-protector -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -L/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -lruby -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib64
配置帮助 1 ./configure --help | grep python
恢复配置 把配置文件复制到原位置即可
如何在 CentOS 7 上安装 Vim 8.2
Vim-8.2.4567
Vim 8 支持 Python 3 的一些坑