Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Created November 14, 2013 23:04
Show Gist options
  • Save nelstrom/7475980 to your computer and use it in GitHub Desktop.
Save nelstrom/7475980 to your computer and use it in GitHub Desktop.
Original draft of [Getting Vim with `+clipboard` support](http://vimcasts.org/blog/2013/11/getting-vim-with-clipboard-support/). Shows what I know!

On OS X

On OS X Mavericks, Apple ships Vim version 7.3 with -clipboard. Here's the gist from running /usr/bin/vim --version on Mavericks (and the same on Mountain Lion). Shame on you Apple!

If you use Homebrew, you can get Vim with +clipboard by running:

brew install vim

Here's a gist from running /usr/local/bin/vim --version.

Alternatively, you could download MacVim. Look inside /Applications/MacVim.app/Contents/MacOS, and you'll see that the app provides two binaries: MacVim, which launches the GUI, and Vim, which runs in the Terminal with the same feature set. Both versions include the +clipboard feature. Here's a gist from running /Applications/MacVim.app/Contents/MacOS/Vim --version.

On Linux

If your Linux distribution ships Vim with the +clipboard feature, leave a comment saying which distribution you use. If not, read on.

I don't run a desktop Linux environment, so I ran some tests against Ubuntu 12.04 inside Vagrant. The default vi binary has -clipboard (gist of vi --version). If you attempt to run vim, it prompts you to install a package:

vagrant@precise32:~$ vim --version
The program 'vim' can be found in the following packages:
 * vim
 * vim-gnome
 * vim-tiny
 * vim-athena
 * vim-gtk
 * vim-nox
Try: sudo apt-get install <selected package>

I tried installing each of these and found that vim-gnome, vim-athena, and vim-gtk each included the +clipboard feature. I've created a gist from running vim --version for each of these packages: vim-gnome, vim-athena, and vim-gtx. The vim and vim-nox packages both had -clipboard. Shame!

Robin Skahjem-Eriksen wrote to me with a tip: you can run GVim inside the terminal by launching it with the gvim -v command. That could be handy if your distribution ship vim with -clipboard, but also ships gvim with +clipboard.

If you have any more tips on how to obtain Vim with the +clipboard feature, please share them in a comment.

Can we fix this?

Being able to access the system clipboard from Vim is essential. It's a nuisance that so many systems ship Vim without the +clipboard feature! I'd like to see that change. Please make the information in this article obsolete by campaigning to have +clipboard enabled by default on your system.

@PezCoder
Copy link

PezCoder commented Sep 8, 2017

Hey, I also use my VIM on daily basis inside my vagrant box in an ubuntu environment inside.
I too have -clipboard for vim.. So the only way to get it is to install one of vim-gnome, vim-athena, and vim-gtk ?

What my assumption is, is that since we're ssh-ing into the virtual box it might not have access to the outer environment.
What do you think this issue is because of ?

@espoelstra
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment