Access the system clipboard from vim
Make terminal vim a first-class citizen with access to copy to/paste from the system clipboard. First off, check that vim was complied with clipboard support:
$ vim --version
If you see +clipboard
, then you're good to go. If you see -clipboard
, then you need to compile vim with clipboard support. (On OS X, brew install vim
will give you vim with clipboard support.)
Next, in your .vimrc
, add:
set clipboard=unnamed
Restart vim and enjoy!
Further reading: Accessing the system clipboard
Written by Brian Riley
Related protips
3 Responses
How do you access it afterwards?
This solution has the side effect that vim will "pollute" your system clipboard. Whenever you yank or remove lines, those lines will replace the system clipboard or append to system clipboard history if you rely on that also.
My solution is easier access to system clipboard:
map <space>y "+y
map <space>p "+p
map <space>P "+P
Polluting the system clipboard is the intention here. If you yank in vim, you can then Cmd+P anywhere else to paste.