Sharing the Mac OS X clipboard with the internal X server

Solution 1:

You can enable clipboard sync by editing ~/Library/Preferences/org.x.X11.plist and adding the following five boolean keys1 (and checking them).

sync_clipboard_to_pasteboard
sync_pasteboard
sync_pasteboard_to_clipboard
sync_pasteboard_to_primary
sync_primary_on_select

Restart X11 and they should be synchronized properly.

Edit: You can add the keys either with the Property List Editor or with the following Terminal commands:

defaults write org.x.X11 sync_clipboard_to_pasteboard -boolean true
defaults write org.x.X11 sync_pasteboard -boolean true
defaults write org.x.X11 sync_pasteboard_to_clipboard -boolean true
defaults write org.x.X11 sync_pasteboard_to_primary -boolean true
defaults write org.x.X11 sync_primary_on_select -boolean true

An alternative solution is to install the latest version of XQuartz which exposes these options through the X11 Preferences >> Pasteboard panel.

Solution 2:

You can also recompile vim-7.3 and add the following to your .vimrc:

set clipboard=unnamed

Then you'll be able to do 'yy' in vim and paste in Cocoa with Cmd+V. And vice versa: copy with Cmd+V in Cocoa and paste in vim with 'p'