Copy text from one tmux pane to another (using vim)

You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:

  1. Ctrl+b, [ Enter copy(?) mode.

  2. Move to start/end of text to highlight.

  3. Ctrlspace

    Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.

  4. Move to opposite end of text to copy.

  5. Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)

  6. Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.

  7. Ctrl+b, ] Paste copied text from tmux clipboard.

tmux is quite good at mapping commands to custom keyboard shortcuts.

See Ctrl+b,? for the full list of set keyboard shortcuts.


Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:

  1. Enter Copies the selected text

If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):

(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)

  • Copy:
    1. Press prefix + [ to enter copy mode.
    2. Use arrow keys to go to the start/end of text selection.
    3. Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
    4. Use arrow keys to move to the other side of selection.
    5. Press ctrl + w.
  • Paste:
    1. Press prefix + ] in insert mode.