Vim yank to tmux clipboard

tmuxvim

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.

Best Answer

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.

Related Question