Sign up ×
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'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?

share|improve this question

8 Answers 8

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.

share|improve this answer
@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
@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

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.

share|improve this answer
+ is a clipboard regiser – Kit Ho Aug 8 '13 at 8:23
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

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
share|improve this answer

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


Very intuitive.

share|improve this answer
Are you using gvim? – nozimica May 3 '11 at 16:14
@nozimica- yeah – ripper234 May 3 '11 at 17:09
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 May 3 '11 at 21:02

An alternative method is to hold down the shift key when copying (this also works for pasting from the clipboard in to vim). This then copies to the clipboard.

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

share|improve this answer
Do you mean holding down the shift key when selecting text? That's the way I do it with xterm. – nozimica May 3 '11 at 19:27
@nozimica: Yes. – Loop Space May 3 '11 at 20:37

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.

share|improve this answer
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
@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.

share|improve this answer

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.

share|improve this answer

Your Answer


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.