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?


12 Answers 12


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 ? Apr 10, 2013 at 2:54
  • 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. Apr 10, 2013 at 11:32
  • 3
    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. Jun 15, 2016 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, 2017 at 18:39
  • 1
    I have +clipboard and -xterm_save . How do I get the +xterm_clipboard?
    – Jdeep
    Jul 22, 2020 at 8:04

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.

  • 3
    @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 Jan 24, 2018 at 14:34
  • 1
    On MAC hold down the option key and select text with the mouse cursor
    – abreschi
    Oct 4, 2019 at 21:26
  • Doesn't work for me using vim 8.0 + gnome-terminal
    – jchook
    Oct 26, 2019 at 21:09
  • Solution not compatible with multipane terms like tmux. Jul 11, 2020 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, 2020 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
    – TheOneTeam
    Aug 8, 2013 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, 2014 at 0:38
  • 2
    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, 2017 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.

  • For Ubuntu 20.04 instead install vim-gtk3
    – an4s911
    Sep 13, 2021 at 9:19
  • I think Arch Linux started building without this recently I think May 24, 2023 at 21:19

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, 2011 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, 2011 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, 2011 at 2:41
  • if you use shift-control mousedrag - select text, copy pasting from one buffers window becomes easy.
    – Stephan
    Nov 3, 2011 at 10:33

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

  • 2
    That does not work.
    – Astrid
    Jun 14, 2017 at 16:57
  • creative answer
    – vidur punj
    Nov 8, 2017 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. Apr 15, 2021 at 2:20

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


Very intuitive.

  • 1
    Are you using gvim?
    – nozimica
    May 3, 2011 at 16:14
  • @nozimica- yeah
    – ripper234
    May 3, 2011 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). May 3, 2011 at 21:02
  • This only works if gvim is installed with vim. If you its vim by itself, this solution does not work.
    – Dave
    Apr 5, 2023 at 16:52

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.


This answer is for macOS users:

I'm adding this because none of the other answers that I tried here worked for me... but this one does! I cannot recall where I found this; I can't claim credit, but I will claim that it works for macOS, and it seems to be "native" to vim so it should work in other systems also:

  1. From vim in your terminal window, enter visual mode by typing v

  2. Select the text you want to copy using the mouse or glidepad

  3. Type "*y; the selected text is copied to the system clipboard

You may now paste the copied text wherever it's needed.

IIRC, " tells vim to select a register; * specifies the system register; y is the yank (copy) command.

  • 1
    I can confirm this works on Windows 10, Terminal, PowerShell 7.3.2 (last version at the time)! Feb 4, 2023 at 9:26

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.

You must log in to answer this question.

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