Last Updated: February 25, 2016
·
1.516K
· xcambar

Vim - Share the default yank register with your system clipboard

Just add this line to your .vimrc:

set clipboard=unnamed

Now, whenever you copy/paste in your system, the content will be available in the default yank register.
And whatever you add to this register (eg, with yy), it will be available in your system clipboard.

There you go!

disclaimer: Found in Paul Annesley's dotfiles. Thanks Paul!

4 Responses
Add your response

This is not completely accurate: unnamed is the * register; in X11 systems (like Linux) '*' is the "mouse clipboard" (the one that let's you paste everything you highlight using the center button of your mouse on many Linux distributions), and '+' is the "proper clipboard" (the one mapped on CTRL+X, CTRL+C and CTRL+V).

To copy from vim to the '+' register you just have to use "+y (that's double quotes, a plus sign and y) and the yanked text will be added to your desktop's default clipboard on Linux.

over 1 year ago ·

Thanks for the clarification!
I'm using a Mac and I must confess I didn't check on Linux at first hand ;)

over 1 year ago ·

note that on OSX at least, if vim is in tmux, it does not work. workaround exists

over 1 year ago ·

What is the workaround when you're running vim in tmux?

over 1 year ago ·