I want to ask about vim+ tmux. I open two file with vim in two tmux pane. How can I copy code from vim in first pane to second pane. I used mode copy of tmux, but It had a number line and created a new line. Thanks for your help!


If the question is How to copy text from one vim window (in one tmux pane) to another vim window (in another tmux pane) then It's a matter of vim-clipboard.

In that case, on your terminal type vim --version | grep clipboard then if output has something like this

+clipboard       +job             +path_extra      +user_commands
+eval            +mouse_dec       +statusline      +xterm_clipboard

Notice the +clipboard means, your vim has clipboard capabilities.

And you can simply copy code by doing this,

Visual Mode

  1. Visually select the text you need to copy.
  2. On your keyboard type "+yy to "yank" text.

Normal Mode

  1. By using numbers you can say 12"+y

  2. Or you can say "+yy to yank the current line.


After you have copied text from one vim window, you can then navigate to the second one and go to INSERT mode then type Ctrl r + Control + r + plus sign which pastes text from vim :REG Type that and see everything stored in them which you can actually replace the plus sign in that code.

If however you have something like -clipboard this means you don't have clipboard capabilities in your vim.

Easiest way is to install vim-nox which has lots of capabilities including clipboard. Or install gvim which will add your terminal vim those capabilities.

While pasting it's important to :set paste before pasting and then :set nopaste after pasting to reserve some formatting from the clipboard text into vim.

Regarding copying with tmux

Well, tmux will treat the whole of your vim as a board and it will just copy everything even the status bar the correct way to copy stuffs from vim is using vim's clipboard capabilities and the correct way to copy stuffs from your terminal is using tmux & xclip.

Here is more about vim clipboard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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