可能要先删除已经安装的vim:
sudo apt-get remove vim vim-runtime gvim
ubuntu12.04上可能还要删除以下包:
sudo apt-get remove vim-tiny vim-common vim-gui-common
然后安装依赖:
sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev ruby-dev mercurial
然后下载源码编译安装如下:
cd ~
hg clone https://code.google.com/p/vim/
cd vim
./configure --with-features=huge \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-perlinterp \
--enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim73
sudo make install
把vim设为默认编辑器,并且自动更新:
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
sudo update-alternatives --set editor /usr/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
sudo update-alternatives --set vi /usr/bin/vim
不过最好是用checkinstall,这样方便卸载。不用上面最后一步sudo make install,用下面步骤:
sudo apt-get install checkinstall
cd vim
sudo checkinstall
checkinstall最后输出如下:
Done. The new package has been installed and saved to
/home/xuelang/vim/vim_20130615-1_i386.deb
You can remove it from your system anytime using:
dpkg -r vim
参考:
https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
Building Vim