How to copy a selection to the OS X clipboard

ʞɔıu picture ʞɔıu · Mar 24, 2009 · Viewed 127.7k times · Source

I have an area selected in Vim. How can I copy it into the OS X clipboard?

(The OS X clipboard can be written to via a pipe to /usr/bin/pbcopy)

Answer

George V. Reilly picture George V. Reilly · Mar 25, 2009

For MacVim and Windows Gvim, simply add the following to your ~/.vimrc:

set clipboard=unnamed

Now all operations such as yy, D, and P work with the clipboard. No need to prefix them with "* or "+.