I'd like to be able to copy and paste between native (Cocoa?) MacOS X apps and those running under Mac's internal X server.

Currently I can copy and paste independently. If I select text in an xterm window I can paste it back in any other X based window. Similarly, copying information outside X can be pasted into applications which are also outside X.

As an example, if I (in exactly this order):

  • Copy (select using the mouse) "Copy using X selection" in an xterm window
  • Copy (Edit | Copy) "Text in Firefox" in Firefox
  • Paste (Shift Insert xmodmap) into nano I get "Copy using X selection"
  • Paste (Edit | Paste) here I get -> Text in Firefox
  • Paste in MacVIM (Edit | Paste) I get "Text in Firefox"
  • Paste into /usr/bin/vim (non graphical) I get "Copy using X selection"

How do I enable "clipboard sharing" between X and Cocoa?

The xmodmap I am using to paste in X is:

xmodmap -e "keycode 84 = Insert"

where 84 is the numeric keypad's Enter key. So Shift Enter gives me paste.

  • Is this consistent across X applications? Are you trying it in plain xterm or similar, not vim or something with its own buffers? Which version of OS X are you running? My clipboard is shared across Cocoa and X11 as expected in 10.5.7.
    – jtb
    Aug 3, 2009 at 6:40
  • Hey jtb, thanks for your help. I use vim and am familiar with the issues around using it's internal buffers. I normally cheat and switch into edit mode then paste from gvim (or MacVim's) edit menu. I've added some extra information to my post to clarify the other parts of your question.
    – kwutchak
    Aug 3, 2009 at 6:59
  • Ah, thanks for the extra info. I'm seeing mostly what you describe although the paste in step 3 works (using middle click, I don't have Insert mapped). Command-C does seem to copy into the native clipboard if I have text selected in X11, but I see what you mean that using the native X copy/paste operations it's not properly synchronized.
    – jtb
    Aug 3, 2009 at 7:24
  • For recent version of OSX (I use 10.12), the following works: stackoverflow.com/a/9525347/1353267
    – Samveen
    Jun 16, 2018 at 12:26

2 Answers 2


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


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.

  • This line typed on my xterm and copied across... ;) This line successfully pasted back into my xterm... ;) Another case where my wife wouldn't understand how extremely satisfying this fix is!! Thank you very, very much.
    – kwutchak
    Aug 3, 2009 at 7:45
  • Thanks for asking. The Mac has me in the habit of hitting Cmd+C to the extent that I didn't realize what I was missing. But I'm quite glad to have this in my config now.
    – jtb
    Aug 3, 2009 at 7:49
  • I have installed XQuarts and changed the options for it. When I ssh to a remote system with XForwarding enabled (on both systems) and add things to the clipboard using xclip (eg: ls | xclip) the clipboard on my local system (mac os x) does not change. What am I missing?
    – cwd
    Mar 29, 2012 at 14:10
  • 4
    I think the correct file to write to now is org.macosforge.xquartz.X11 Mar 31, 2014 at 20:58

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'

  • notice that your vim has to be compiled with the clipboard option on in order for this to work. You can see if it is by executing vim --version | grep clipboard. If it says +clipboard, then you are good. If it says -clipboard, this will not work.
    – egarcia
    Aug 22, 2013 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .