Skip to content

Instantly share code, notes, and snippets.

@laurilehmijoki
Last active August 29, 2015 13:56
Show Gist options
  • Save laurilehmijoki/8911939 to your computer and use it in GitHub Desktop.
Save laurilehmijoki/8911939 to your computer and use it in GitHub Desktop.
Use system clipboard with VIM

Problem

The "integrate VIM with the system clipboard" feature does not work on OS X 10.8+ and VIM 7.3.

Solution

  • Compile VIM from source
  • Enable the system-clipboard integartion in .vimrc

Compile VIM

hg clone https://vim.googlecode.com/hg/ vim # get Mercurial: http://mercurial.selenic.com
sudo mkdir -p /opt/local/bin # Do not override the system VIM
cd vim
./configure --prefix=/opt/local --with-features=huge
make
src/vim # Try out the VIM that we just compiled
sudo make install # Install to /opt/local

Ensure that the dir /opt/local/bin is in your $PATH.

Integrate with system clipboard

Add the following setting into your .vimrc.

set clipboard+=unnamed " Always yank/delete to system clipboard

Done!

Restart VIM. Try yanking any selection in VIM and then pasting the selection into another window, e.g. TextEdit. It should work.

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