Copy/paste has never worked properly in all cases in GNU/Linux, for decades, and this problem is still not fixed.

I find myself with two xfce4-terminal instances, terminal A and terminal B.

Terminal A is at a bash command prompt. Terminal B is in a vim instance, editing some arbitrary file.

I attempt to copy/paste text from B into A, by highlighting the text in B with the mouse cursor. The text becomes successfully highlighted. I use the middle button in terminal A.

Expected results:

The text from terminal B should be copied into terminal A.

Actual results:

The previous entry in the clip buffer gets dumped in terminal A instead.

My "fix":

Get out of vim and use less or similar command line tools, copy the text without being in vim. Then it works as expected.


Is there a better fix?

  • Have you tried Right Click->Copy and Right Click->Paste? or Copy & Paste from the terminal's Edit menu? or highlight to select in the source terminal and then Edit Menu->Paste Selection. All of those work for me in xfce4-terminal. standard middle-button paste works for me most of the time (but that depends on what the source program does - some apps like to use the clipboard for selections instead of just the select buffer).
    – cas
    Oct 5, 2019 at 10:42
  • btw, it might help if you set mouse= and ttymouse= (i.e. null arguments) in your .vimrc. IMO vim's mouse handling sucks so I disable it. That may be why copy-paste works for me....it's been so long since i've allowed vim mouse handling that I can't remember how it behaved.
    – cas
    Oct 5, 2019 at 10:44
  • See vi.stackexchange.com/q/84 Make sure your version of Vim has +clipboard support. I recommend Neovim.
    – Devon
    Oct 5, 2019 at 15:57
  • @Devon Even in +clipboard enabled vim I have exactly the same problem. It furthermore makes no sense to me that this is a feature dependent on vim. vim runs inside the terminal emulator and shouldn't at all affect what text can be selected from a GUI window that merely displays the output of vim. May 3, 2020 at 13:39

5 Answers 5



  • vim --version says -clipboard:

[Shift]+Left-Mouse-Button selection to copy from Vim, Shift+Insert or Middle-Mouse-Button or Edit > Paste selection to paste it in Xfce4-terminal.

  • vim --version says +clipboard:

    Option 1: [Shift]+Left-Mouse-Button selection to copy from Vim, Shift+Insert or Middle-Mouse-Button or Edit > Paste selection to paste it in Xfce4-terminal.

    Option 2: Yank text to * register. For example, "*Y to yank the whole line. Paste it in Xfce4-terminal with Shift+Insert or Middle-Mouse-Button or Edit > Paste selection.

    Option 3: Yank text to + register. For example, "+Y to yank the whole line. Paste it in Xfce4-terminal with Ctrl+Shift+V or Edit > Paste.

The [Shift] in brackets is optional if your Vim does not mouse enabled. The above description will also work for other terminals, except Option 3 and menu items (Edit > ...).


There are two main "clipboards" around: Primary and Clipboard. The content of Primary is set simply whenever text is selected. It needs one more action to get to Clipboard, usually a keyboard shortcut (a widespread one is Ctrl+C) or a menu item. Pasting from Primary is done with Middle-Mouse-Button (many terminals also use Shift+Insert). Pasting from Clipboard may be done with Ctrl+V, Ctrl+Shift+V... It is all up to the application.

  • Xfce4-terminal pastes from Primary with Shift+Insert or Middle-Mouse-Button or Edit > Paste selection menu item. It pastes from Clipboard with Ctrl+Shift+V or Edit > Paste. It copies to Primary with mouse selection and to Clipboard with Ctrl+Shift+C or menu item.

  • Minimalist terminal emulators such as Xterm have only Primary enabled by default (but it can be made to support Clipboard).

  • If +clipboard is enabled, Vim associates register * to Primary and register + to Clipboard.

If Vim is running in a terminal emulator and Vim's mouse support is on (:set mouse=a), then the mouse selects text to Visual mode. If you want the terminal's capability to select to Primary, then you need to press Shift while selecting with the mouse. From :help mouse:

Note: When enabling the mouse in a terminal, copy/paste will use the "* register if there is access to an X-server. The xterm handling of the mouse buttons can still be used by keeping the shift key pressed.

That is a common pattern of text-terminal tools that support mouse. For example, start nano without mouse support and with mouse support, nano --mouse. In the first case, you can simply select text with mouse, but in the latter case, you also need shift to be pressed just as with Vim. With Midnight Commander the same happens with mc --nomouse and mc. All those utilities mention it in their manuals.

You also may find this Freedesktop specification informative.


You can use the terminal in vim mode. If you type in the terminal console, set -o vi The terminal keyboard layout now switches to vim mode.

another way: copy / cut mouse clipboard paste in the terminal


  • This doesn’t answer how to copy from Vim.
    – Devon
    Oct 5, 2019 at 16:02
  • because we don't copy mouse on the vim, if you standard mode on the vim, you chanced mode v, Visiual mode and we keypress J belove line select or K above line select than yy command than for paste pp command
    – Erdal
    Oct 5, 2019 at 16:29
  • 1
    vi users usually don't use a mouse
    – Erdal
    Oct 5, 2019 at 16:37

In some terminal applications, for instance less you can not directly copy text. But you can copy text if you hold the space key whilst copying. Does that answer your question?


$ emacs --eval '(term "/bin/bash")'

 - C-c C-k     char mode
 - C-c C-j     line mode
 - C-space     Select text
 - M-w         copy    to X11 buffer

In VIM you can do:

Press v to enter in visual mode. With the keyboard arrows move the cursor to select that you want to copy.

Then press "+++yy (Double quote + Plus Symbol + YY)... Yes, the "y" letter twice

Once it is done, in the other terminal copy in the conventional form: Ctrl+Shift+V

There are many other great options with registers. Please see: https://vim.fandom.com/wiki/Copy,_cut_and_paste

  • From the reference you provided: "Assuming Vim was compiled with clipboard access, it is possible to access the "+ or "* registers (...)". That is a very important information. Many do not have +clipboard option, so this will not work.
    – Quasímodo
    May 7, 2020 at 16:21
  • I don't agree with the -1 qualification.
    – asdfgh
    May 8, 2020 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .