I have install Vim 8 (so that I can use ale). Unfortunately I can't seem to get the system clipboard to work. (E.g. using vim-gnome I would use the "+y to yank to the system clipboard. Has anybody got this working?

I installed Vim 8 using:

sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
  • This version of vim is compiled without clipboard support. You can see that with vim --version | grep clipboard and see it comes up as -clipboard instead of +clipboard. I don't know of any prebuilt vim 8 packages for ubuntu 16 that have clipboard. – Matt Greer Apr 23 '18 at 0:02
  • @MattGreer that's odd. I use the jonathanf/vim PPA on 16.04, and I have +clipboard. OP: What does update-alternatives --display vim report? Is it pointing to vim.gtk3? – muru Apr 23 '18 at 1:42
  • @muru apologies I may have conflated a couple of issues. I'm pretty sure when I posted this I was actually using elementary os. In between then and posting my answer, I switched to 17.10 and encountered a similar problem. That's when I ended up building from source. It's entirely possible that this is not actually an issue on 16.04, but I don't currently have a machine with that installed to check on this further. – jerome Apr 23 '18 at 20:25
  • @muru your comment prompted me to look a little more and you are right. If after adding the jonathanf/vim PPA you apt install vim, it installs vim.basic. If you instead apt install vim-gtk3, then you get vim.gtk3 which has +clipboard – Matt Greer Apr 24 '18 at 2:53
  • @jerome what Matt says^: the vim package's vim.basic has lots of features disabled (on Debian/Ubuntu and on PPAs which build on the existing packaging) - it's just a few steps above the vim.tiny installed by default. You should install one of the GUI Vims or vim-nox for more features (but vim-nox understandably has clipboard support disabled). This is true of all versions of Ubuntu and Debian, though the GUI Vim packages may have different names. – muru Apr 24 '18 at 6:19

If after adding the jonathanf/vim PPA you apt install vim, it installs vim.basic. If you instead apt install vim-gtk3, then you get vim.gtk3 which has +clipboard, and thus the system clipboard. Regardless of which one you install, it will get symlinked to /usr/bin/vim

(converted my comment to an answer in case anyone else stumbles into here)

  • 1
    I can confirm that installing vim-gtk3 using jonathanf/vim repo works just fine, and is more straightforward than building from source. Changing the above to the accepted answer. – jerome May 2 '18 at 1:32
  • Perhaps an obvious comment, but it's worth noting this is still a regular terminal Vim and not GVim, even though the 'g' in gtk might mislead you. – icc97 Jun 18 '18 at 0:49

I was able to get what I needed by building from the source with the following:

$ sudo apt-get remove vim # to remove the binary I had installed
$ sudo apt build-dep vim
$ git clone git@github.com:vim/vim.git
$ cd vim/src
$ ./configure --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-cscope \
            --prefix=/usr \
            --enable-gui=auto --enable-gtk2-check --with-x # this is what I needed
$ make
$ sudo make install
  • If anybody gets stuck with the error on sudo apt build-dep vim You must put source URLs in your sources.list file, this answer would be helpful! – aspiring1 Dec 24 '19 at 6:28
  • Also, using --with-python3-config-dir=$(python3-config --configdir), is better since it gives the config directory searching by itself, even if you are using miniconda/anaconda for python. Also, using sudo checkinstall instead of make should be better as it leads to ease in uninstallation! – aspiring1 Dec 24 '19 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.