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!
Written by Xavier Cambar
Related protips
4 Responses
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.
Thanks for the clarification!
I'm using a Mac and I must confess I didn't check on Linux at first hand ;)
note that on OSX at least, if vim is in tmux, it does not work. workaround exists
What is the workaround when you're running vim in tmux?