Yangbo's Blog

Vim Tips

I’ve been using Vim and some handy plugins for a while. Today when I was trying to use the “copy-to-clipboard” combo-key "+y in Vim, I found that it didn’t work for me. After doing some Google search I realized that to use the “copy-to-clipboard” function the Vim has to enable GUI. However, the Vim on my computer didn’t support GUI:

1
2
3
4
5
6
7
8
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
Included patches: 1-1689
Extra patches: 8.0.0056
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Huge version without GUI. Features included (+) or not (-):
...

I followed the link to install vim-gtk. But after the installation the default Python interpreter for Vim is changed to python3. When I was configuring the Vim plugin YouCompleteMe before, I ran into some incompatiable issues with python3, and had to switch to python.

1
2
3
$ vim --version | grep python
+cryptv +linebreak -python +vreplace
+cscope +lispindent +python3 +wildignore

I’ve forgot how I made it to change back to python before. So I recompiled Vim from source this time and made some notes below:

Remove current Vim installation

For removing Vim using aptitude, refer to link:

1
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common

For removing Vim installed from source, cd to the source code directory and run commands below

1
2
3
4
make clean
./configure
make
sudo make uninstall

Install Vim8.0 from source

Download the source code:

1
2
git clone https://github.com/vim/vim.git
cd vim/

Don’t forget to add the --enable-gui option:

1
./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/usr/lib/python2.7/config --enable-gui=auto --enable-cscope --enable-multibyte --prefix=/usr

If the above command fails to work, and displays an error like checking for tgetent()... configure: error: NOT FOUND!, you’ll need to install a library according to this link.

1
sudo apt install libtinfo-dev

If you want to be able to easily uninstall Vim in the future, use checkinstall (refer to link):

1
2
sudo apt-get install checkinstall
sudo checkinstall

Otherwise, run sudo make install to finish the installation.

Double check the new version

1
2
3
4
5
$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 24 2017 16:18:02)
Included patches: 1-503
Compiled by ylong@ylong-Gazelle
Huge version with GTK2 GUI.