Given I am SSHed into a server and have tmux running, is there any straightforward way to be able to yank into a register in vim and:

  • have that text be available in my tmux clipboard?
  • have that text available in my osx clipboard?

I know how to copy/paste in tmux and iterm2 seems to handle passing that onto my osx clipboard. However there are times when I want to yank text in a vim split screen and the tmux copy/paste won't do. Anyone figured this out?

Thanks so much!


One method would be to create a vim function that uses redir or writefile to dump the yanked register into a file, use tmux load-buffer to get it into the tmux clipboard, and then delete the file.

To get the remote tmux clipboard into the OS X clipboard, I use ssh HOST tmux show-buffer | pbcopy.

Both of these are kind of annoying, but I don't know of any better ways to do this.

  • Thank you. Not ideal, but I appreciate the solution! – Aaron Gibralter Aug 19 '14 at 21:48

Part of your answer is to run tmux locally on your mac before you SSH out. Then you are working with your local tmux to copy/paste. Again, not super ideal if you need to grab more lines of code in a remote vim session that are greater in size than your current screen, but it works for most scenarios.

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.