3

In a tmux session, I'm running vim in one pane and a terminal in another pane.
Recently, I figured out how to enter visual mode in tmux but it doesn't help much now.

Can I yank selected text from a pane and paste it to another (within vim or not), and how can I do this?
The other way, how can I yank some text from vim and paste it to another pane?

2
  • I could have sworn Ive answered something like this before, but I can’t find it. The answer is yes, there are tmux bindings that allow this (and tpope has a plugin, tbone I think, that makes it easy in vim). But if your question is about tmux and not vim, it’s off-topic here.
    – D. Ben Knoble
    Commented Sep 22, 2020 at 12:36
  • Welcome to Vi and Vim!
    – filbranden
    Commented Sep 22, 2020 at 17:45

2 Answers 2

1

Plugin vim-tmux-clipboard seems to be what you're after. It mirrors Vim's unnamed register (default one for yank, delete and put operations) to and from the tmux clipboard.

Make sure you take a close look at the requirements when enabling this plug-in. For Vim, you need at least version 8.0.1394 and you also need plug-in vim-tmux-focus-events to be enabled. (For NeoVim, there are no additional requirements.)

You also need to enable set -g focus-events on on tmux for it to work.

0

I am not sure how to paste to terminal, but you can make the two vim instances share the same clipboard. First check that if your vim supports clipboard by typing vim --version, if you see +clipboard in the output, then in your ~/.vimrc, add

set clipboard=unnamed

now you can freely yank and paste between tmux panes and windows.

2
  • Note that this also means copying text in other applications changes what will be put by default
    – D. Ben Knoble
    Commented Nov 3, 2021 at 13:11
  • @D.BenKnoble Thanks for reminding, that is a little bit tricky...
    – zyy
    Commented Nov 4, 2021 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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