Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another.

How can I accomplish this not using the mouse's Copy -> Paste ?

share|improve this question
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines, :w /tmp/lines, then :r /tmp/lines in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the + or * registers to avoid the temporary file. – Chris Johnsen Dec 19 '12 at 5:39
up vote 21 down vote accepted

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.

  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.

share|improve this answer
This was just great. Thanks! – Ionică Bizău Jul 10 '14 at 10:40

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
share|improve this answer

You could use the system clip board with "*y and "*p instead of the normal y and p.

share|improve this answer
To use system clipboard you have to use "+2yy – copy two lines to X11 clipboard "+dd – cut line to X11 clipboard "+p – paste X11 clipboard – Patryk Jan 9 '13 at 12:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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