I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block.

It appears to copy the text into vim's clipboard, because p will paste it. But in another program (e.g. Chrome), right-click->paste doesn't paste the correct text. How do I copy text to the correct clipboard?


11 Answers 11


The following will work only if vim --version indicates that you have +xterm_clipboard feature. If not, you will have to install extra packages or recompile vim with that feature added.

There are actually two options for this:


copies to the "usual" clipboard buffer (so you can paste using Ctrl+V, right click and select "Paste" etc), while


copies to the X11 selection - you can paste from this buffer using middle click.

Note that "* and "+ work both ways. So if you have selected some text in another application, you can paste it into vim using "*p and if you have copied some text (using, say, Ctrl-C) then you can paste it into vim using "+p.

  • 2
    @Tshepang it is not working from putty. what should I do ? – Rahul Patil Apr 10 '13 at 2:54
  • @RahulPatil I know not; maybe ask a separate question, perhaps on Super User (since it's a Windows tool, it would be more welcome there). – tshepang Apr 10 '13 at 5:19
  • 1
    @RahulPatil - if you are using putty then you are editing the file on a remote server, not on your local machine. Generally the remote server won't know about the clipboard on your local machine. If you were using a Linux desktop then you can ssh with X forwarding (provided you have installed the X libraries on the server), but as putty runs on windows you don't have X running so you can't forward it. – Hamish Downer Apr 10 '13 at 11:32
  • 2
    Hello everybody, How to type "+y ? should i type it in Visual mode or in command mode ? Silly thing, but i am unable to figure it out. – Alind Billore Jun 15 '16 at 12:38
  • 1
    @AlindBillore: In command mode. Literally, press the keys shift' then shift= then y (not all at once, one after the other, except the shifts of course). – Reid Mar 30 '17 at 18:39

Hold down the shift key and select text with the mouse cursor.
Text will be copied to the clipboard.

This also works for pasting from the clipboard in to vim.

To be clear, this works for vim running in a terminal such as xterm.

  • 2
    @LoopSpace for multiline selections this will also copy line numbers too when set nu is enabled. So u would probably want to toggle line numbers with some shortcut or run the :set nonu command before every selection – Steven Pribilinskiy Jan 24 '18 at 14:34
  • On MAC hold down the option key and select text with the mouse cursor – abreschi Oct 4 '19 at 21:26
  • Doesn't work for me using vim 8.0 + gnome-terminal – jchook Oct 26 '19 at 21:09
  • Solution not compatible with multipane terms like tmux. – Adrian Lopez Jul 11 '20 at 13:18
  • This does not copy to the clipboard, this copies to the primary. See the distinction in Clipboard Arch Wiki article. – Quasímodo Aug 4 '20 at 17:15

If you are using vim >=7.3.74, then you can actually put this in your vimrc:

set clipboard=unnamedplus

Which will automatically use the + buffer (the system clipboard) by default. Then to yank (copy), you just use the regular y command, etc.

I found this behavior to be fairly annoying, though, as commands like d put the text they operate on into the default buffer, which meant I couldn't do a fast dd and paste a line from the internet, for example.

  • 2
    + is a clipboard regiser – Kit Ho Aug 8 '13 at 8:23
  • 2
    Regarding your last point, dd means "cut one line", so that would be the expected behavior. In the rare case when you want to actually delete a line into oblivion, "_dd will do the trick. – user7089 Apr 24 '14 at 0:38
  • 1
    also as @HamishDowner notes in his answer: The following will work only if vim --version indicates that you have +xterm_clipboard feature. If not, you will have to install extra packages or recompile vim with that feature added. – rudolph9 Mar 30 '17 at 15:51

I find the standard "+gP and "+y commands very difficult to use. So I've remapped Ctrl-Y for yanking into the clipboard and Ctrl-P to paste from the clipboard. Add this to .vimrc

nnoremap <C-y> "+y
vnoremap <C-y> "+y
nnoremap <C-p> "+gP
vnoremap <C-p> "+gP

When I checked my vim was not supporting clipboard:

vim --version | grep clip
-clipboard       +insert_expand   +path_extra      +user_commands
+emacs_tags      -mouseshape      +startuptime     -xterm_clipboard

I installed vim-gnome and then checked again

vim --version | grep clipboard
+clipboard       +insert_expand   +path_extra      +user_commands
+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard

Now I am able to copy and paste using "+y and "+p respectively.


Never mind, I found the answer - it's written on the vim's menus.


Very intuitive.

  • Are you using gvim? – nozimica May 3 '11 at 16:14
  • @nozimica- yeah – ripper234 May 3 '11 at 17:09
  • 1
    That's also available in vim running in an xterm or similar terminal emulator under X (if vim is compiled with the +xterm_clipboard feature). – Gilles 'SO- stop being evil' May 3 '11 at 21:02

Hold down the SHIFT key and mouse select text to copy it.

Then paste in other program with CTRL + v.

Works in terminal on my Ubuntu 16.04. Not sure about gvim and other systems.

enter image description here

  • That does not work. – Astrid Jun 14 '17 at 16:57
  • creative answer – vidur punj Nov 8 '17 at 12:00
  • For me it worked fine. Hold shift key before starting selecting. The selection gets a different color, the vim bar will not be "VISUAL" and the terminal menu will enable the Copy option. – Sergio Abreu Apr 15 at 2:20

Just to add a non-vim-specific answer: You can use Ctrl+Shift+C to copy to the system clipboard in Ubuntu (if the functionality is provided by your terminal emulator, gnome-terminal for one provides it). Ctrl+Shift+V pastes to another terminal window, regular Ctrl+V pastes to a GUI app.

Additionally, if you select the text in the terminal, then middle-click, it will be pasted from the X11 clipboard.

  • For some reason it doesn't work. Just select with visual mode, copy with ctrl-shift-C, then paste in another app using Ctrl-shift-V ? The text doesn't get copied for me. – ripper234 May 3 '11 at 23:14
  • 2
    @ripper234: this does not work if you are using gvim. As crazy2be said, this functionality is from your terminal emulator. – Reid May 3 '11 at 23:20
  • @ripper234: 1) It is functionality provided by your terminal emulator (gnome-terminal for one provides it), 2) Ctrl+Shift+V is to paste to the terminal, GUI apps still use Ctrl+V as per usual. I'll edit the answer to make it more clear. – crazy2be May 4 '11 at 2:41
  • if you use shift-control mousedrag - select text, copy pasting from one buffers window becomes easy. – Stephan Nov 3 '11 at 10:33

By default, if you install the light version of vim, then you will not have the +xterm_clipboard feature on (vim --version | grep xterm), which is needed for using the * and + registers outside of vim.

To enable it, you must either compile vim yourself, or install a version of vim that comes with it preenabled. I used vim-gnome: sudo apt-get install vim-gnome. If you perform vim --version | grep xterm, you will see that it is now +xterm_clipboard.

Now, try copying to the + and * and it should work.


Just to add, if anything works try to switch the terminal that wraps vim (if you are using vim from the terminal). I found that, for example, the clipboard is inaccessible by guake while is accessible from gnome-terminal.


For Ubuntu 14.04 And Above:

  • Just select the text which you wanna be copy. And then click the centre roll button with your mouse and Go to the clipboard

  • And do the same there too (click the centre roll button with your mouse).

It's 100% working in both vim and tail on Ubuntu.

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