Take the 2-minute tour ×
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.

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
add comment

2 Answers

up vote 9 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
add comment

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
add comment

Your Answer

 
discard

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.