ubuntu 16.04下编译全功能vim8.0

十里又又又在公司的笔记本上安装了Ubuntu,已经无法忍受windows下蹩脚的vim体验,在ubuntu下尝试使用与系统剪切板的交互命令结果让人失落呀,找了一大圈还是没找到支持clipboard的vim,毅然决然的决定自己编译一个全功能的vim!

编译vim

卸载原有的所有vim

sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
有可能之前使用checkinstall安装了vim,可以通过`dpkg -r vim`和`sudo rm -rf /usr/local/share/vim /usr/bin/vim`卸载一下试试!

安装编译vim需要的依赖包

sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev

下载源码

cd ~/Downloads
git clone https://github.com/vim/vim
cd vim
git pull && git fetch

配置编译

./configure \
--enable-multibyte \
--enable-perlinterp=dynamic \
--enable-rubyinterp=dynamic \
--with-ruby-command=/usr/local/bin/ruby \
--enable-pythoninterp=dynamic \
--with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
--enable-python3interp \
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu \
--enable-luainterp \
--with-luajit \
--enable-cscope \
--enable-gui=auto \
--with-features=huge \
--with-x \
--enable-fontset \
--enable-largefile \
--disable-netbeans \
--with-compiledby="yourname" \
--enable-fail-if-missing

编译并安装

make && sudo make install

测试一下

  • 先看一下版本信息

    VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 14 2017 19:00:28)
    包含补丁: 1-642
    编译者 yourname
    巨型版本 带 GTK2 图形界面。
      可使用(+)与不可使用(-)的功能:
    +acl             +file_in_path    +mouse_sgr       +tag_old_static
    +arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
    +autocmd         +float           +mouse_urxvt     -tcl
    +balloon_eval    +folding         +mouse_xterm     +termguicolors
    +browse          -footer          +multi_byte      +terminfo
    ++builtin_terms  +fork()          +multi_lang      +termresponse
    +byte_offset     +gettext         -mzscheme        +textobjects
    +channel         -hangul_input    -netbeans_intg   +timers
    +cindent         +iconv           +num64           +title
    +clientserver    +insert_expand   +packages        +toolbar
    +clipboard       +job             +path_extra      +user_commands
    +cmdline_compl   +jumplist        +perl/dyn        +vertsplit
    +cmdline_hist    +keymap          +persistent_undo +virtualedit
    +cmdline_info    +lambda          +postscript      +visual
    +comments        +langmap         +printer         +visualextra
    +conceal         +libcall         +profile         +viminfo
    +cryptv          +linebreak       +python/dyn      +vreplace
    +cscope          +lispindent      +python3/dyn     +wildignore
    +cursorbind      +listcmds        +quickfix        +wildmenu
    +cursorshape     +localmap        +reltime         +windows
    +dialog_con_gui  +lua             +rightleft       +writebackup
    +diff            +menu            +ruby/dyn        +X11
    +digraphs        +mksession       +scrollbind      -xfontset
    +dnd             +modify_fname    +signs           +xim
    -ebcdic          +mouse           +smartindent     +xpm
    +emacs_tags      +mouseshape      +startuptime     +xsmp_interact
    +eval            +mouse_dec       +statusline      +xterm_clipboard
    +ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
    +extra_search    -mouse_jsbterm   +syntax          
    +farsi           +mouse_netterm   +tag_binary      
         系统 vimrc 文件: "$VIM/vimrc"
         用户 vimrc 文件: "$HOME/.vimrc"
     第二用户 vimrc 文件: "~/.vim/vimrc"
          用户 exrc 文件: "$HOME/.exrc"
        系统 gvimrc 文件: "$VIM/gvimrc"
        用户 gvimrc 文件: "$HOME/.gvimrc"
    第二用户 gvimrc 文件: "~/.vim/gvimrc"
           defaults file: "$VIMRUNTIME/defaults.vim"
            系统菜单文件: "$VIMRUNTIME/menu.vim"
             $VIM 预设值: "/usr/local/share/vim"
    编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
    链接方式: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux   -ldl  -L/usr/lib/x86_64-linux-gnu -lluajit-5.1 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt
    

    试了一下可以用+*寄存器了。

打包vim的deb包

可以使用checkinstall工具对编译的vim进行打包生成deb安装包,方便以后直接安装。

安装checkinstall

sudo apt-get install

生成deb包

cd vim
sudo checkinstall

点我下载十里编译的巨型版本vim安装包,嘎嘎!密码: vhdd