I see a lot of explanations of how to make vim copy to the system clipboard (involving xclip for linux or pbcopy or OSX), but I would like to yank to the tmux clipboard. To be clear, what I want is to position my cursor over a word and hit something like "*yiw and then hop over to another window with tmux (maybe one where I want to paste a large URL for curl or wget) and press Ctrl-B ] to paste (or with whatever tmux prefix key you use). Thanks for help that any one can offer. It would be awesome if this is possible.

  • Why don't you simply install a vim built with clipboard support? – romainl Oct 17 '14 at 14:42
  • That is what I have decided on. It still isn't really satisfactory for a headless machine (without X installed), but it works fine for my usual setup. – Andrew Thaddeus Martin Oct 17 '14 at 15:22

It is not clear why you should use tmux clipboard.

I find it easier to copy to system clipboard from vim or any other application and them paste it on tmux. You could try following on your ~/.tmux.conf:

bind-key -n C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

This allows to paste from system clipboard to tmux using Ctrl-V.

For further information on this approach: Tmux: Clipboard Integration.

  • You are correct. Using a system clipboard as an intermediary seems to be the way to go. Do you know if vim can be configured to yank to a clipboard other that xclip? My idea is that if it could, then this could work on a headless machine without X installed. The binding you gave (and the ones in the link) could certainly be adapted to use another clipboard program. – Andrew Thaddeus Martin Oct 17 '14 at 15:26
  • I believe vim uses the system clipboard, unaware if it is xclip or not. You may find additional information in :help 'clipboard' and on this answer. – mMontu Oct 17 '14 at 16:04

If youre working on a terminal and not a local vim process consider using vim-tbone which enables storing selections to the tmux buffer. It is a basic configuration to map the :Tyank :Tput commands to keyboard shortcuts of your choice (I use ty and tp respectively)

  • 1
    This should be the accepted answer, as it actually answers the original question. The currently accepted answer dodges the question. – Yetanotherjosh May 22 '17 at 21:30
  • Exactly what I needed – nick-s Jun 14 at 11:48

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.