I'm having an issue where text yanked to unnamed is not available to paste afterwards. This only occurs when I am SSHd in to another machine. Both machines are running identical versions of OS X (10.9.2), Vim (7.4, compiled with brew install vim --override-system-vim) and the output is the same on both machines:

vim --version | head -n 2
=> VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 12 2014 13:11:40)
=> MacOS X (unix) version

:echo has("clipboard")
=> 1

:set clipboard?
=> clipboard=unnamed

In a document, when I yank text and then immediately attempt to paste it, I see E353: Nothing in register *. I have also tried "*y and receive the same error. When I enter insert mode and cmd-v, it pastes the last thing I copied outside of vim. I tried "+y, then "+p but receive the same error (referencing *) which I believe is expected, and cmd-v still does not paste what I want.

How do I get vim clipboards to work properly when I am SSHd across machines?


Your machines don't share a common clipboard: what's copied here can't be pasted there and vice-versa.

X11 Forwarding is a very easy and common solution, it allows you to share clipboards and even run remote X-based GUI applications locally but, even if I do that routinely from Mac OS X to Linux, I have no idea if it works between two Macs. I suppose it could be possible if both have XQuartz running but I've honestly never tried (and can't at the moment).

You could try the following:

  1. start X11 on both Macs,
  2. on the "client", connect to the "server" with $ ssh -X username@host

See if you are able to copy stuff from/to both machines.

It is my opinion, though, that such workflows are horribly fragile and needlessly complicated.

  • I'll give that a shot, thanks for the heads up. In the meantime, I have a question: if I'm SSH'd in to a machine, shouldn't yank and paste both be run within the context of the remote machine? In the simple example of one vim session with one buffer, vim should be using the same register for both operations, correct? Is the issue because it's being sent to unnamed, and I should instead account for SSH instances and force vim to copy to a different register in that case? – Josh Whittington Apr 4 '14 at 20:51
  • The only Vim registers that can be seen from outside of Vim are * and +. On Mac OS X, they are just the same so using one or the other doesn't matter and set clipboard=unnamed makes it all irrelevant anyway because what you yanked in Vim is put into the system's clipboard. X11 is set by default (you should check that) to "capture" Mac OS X's clipboard so, thanks to X11 Forwarding, you can paste locally what you copied on your server and paste remotely what you copied on your client. It works very well between two Linuxes or between Mac OS X and Linux. – romainl Apr 4 '14 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.