I based my vimrc file on a popular thread here on SO, and although it's great I have a real problem when it comes to copying text from vim to other linux applications. I suspect the error lies in this vimrc since I can copy when vim is loaded from a blank vimrc file.

What's wrong here?

Bonus question: how do i copy from my guest ubuntu to windows?

My vimrc file can be found here: http://dpaste.org/X4MY/

  • 1
    Are you using vim or gvim?
    – Benoit
    Commented May 28, 2011 at 14:21
  • vim. i'm in ubuntu.
    – DevX
    Commented May 28, 2011 at 14:27

7 Answers 7


Nothing in your .vimrc file strikes me as a problem except perhaps the line

set clipboard+=unnamed

The issue is that the exclude term of the 'clipboard' option, which is present by default if X is detected, must be the last term. By using +=, you have made unnamed the last term. A better setting would be

set clipboard^=unnamed

which places unnamed first in the option string.

Something else you might try, since an empty .vimrc works for you, is to do a binary prune of your .vimrc file. That is, put a :finish command as the first line in your .vimrc file, restart vim and verify that copying works, then move the :finish command about halfway down your .vimrc file, restart vim and try again. Repeat, trying to narrow down the region that contains the problematic command(s). Commenting-out lines works instead of the :finish command, too. You can keep your .vimrc file open in one Vim while restarting a different Vim to make the whole process go a little faster.

  • 2
    The :finish command helped me to triage the problem. The "set mouse=a" line was the culprit. thanks!
    – DevX
    Commented May 29, 2011 at 2:09
  • 1
    I assume you're trying to copy/paste by selecting the text and then middle clicking in another window. If you're running vim in a terminal and have set mouse=a, vim gets the mouse clicks instead of your terminal application, so when you click and drag you're selecting text in vim's visual mode. This is very useful within vim, and you may not want to just disable it. If you want to select, you need to find a control key that causes the clicks to be handled by your terminal instead of vim. If you were using putty, you'd simply hold shift while selecting. What terminal program are you using?
    – mkomitee
    Commented May 29, 2011 at 18:07
  • Seconding the problem with "set mouse=a" and usefulness of :finish. Thanks!
    – Stew
    Commented Jul 16, 2014 at 21:47

How do you copy things from Vim? Vim uses several registers where the +-Register is used to share information with the systems clipboard. For instance, to copy a whole line into systems clipboard use


After that just use CTRL-V to paste like always.

  • 1
    I've seen this suggestion in several places, but it doesn't work for me.
    – DevX
    Commented May 28, 2011 at 15:06

Press the shift key when selecting text if you have mouse support enabled on vim. The normal selection (without shift) enables VISUAL mode. Using shift passes mouse events to your terminal emulator.

  • Ok, this is getting me closer to my goal. I can now copy when i hold down shift (previously copy command was disabled in context menu). The only problem is that it also copies my line numbers. i don't want that. any tips?
    – DevX
    Commented May 28, 2011 at 15:08
  • If you press the shift key while copying or pasting, you are using the terminal's copy and paste functionality, not Vim's, so you will copy what the terminal "sees", which includes the line numbers. This is working around the problem, not solving it.
    – garyjohn
    Commented May 28, 2011 at 17:52

From one of your comments:

I've seen this suggestion in several places, but it doesn't work for me.


You probably don't have vim installed with the clipboard feature enabled, which is required for being able to copy/paste to/from the system clipboard.

If you type vim --version at the command line, you'll probably see -clipboard in the features list. Try compiling vim from source with the following option:

 ./configure --with-features=huge

(include other options you need) and then proceed with make and make install. Now you should see a +clipboard in your features list and you can yank to the system clipboard using


and paste from the system clipboard using

  • You might also be able to install extra packages rather than compiling from source. I installed vim-gui-common in Kubuntu 12.10. Commented Feb 13, 2013 at 8:38

About your bonus question: I know it's unsophisticated, but I tend to have apache running on all my machines - physical and virtual - and so I can copy files somewhere in the document tree and have them visible (and downloadable) from all the other machines.


But I like mouse support!

After hunting through the help docs I also found this little gem:

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.

Sure enough, holding shift allows regular old copy paste with PuTTY.


Comment the line

set mouse=a

in the .vimrc file.

You must log in to answer this question.

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