Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I don't understand the middle click paste.

Sometimes I highlight text, middle click in the window where I want it to go and it does what I want. Sometimes it doesn't.

For instance, when I highlight text in Firefox, then go and middle click into terminal vim, nothing happens.

What is going on?

Thank you!

share|improve this question

2 Answers 2

up vote 15 down vote accepted

Caused by separate X/DE clipboards; keep them synchronized with ClipIt

  • As ImaginaryRobots' answer explains there are two different clipboards: the X clipboard and the desktop environment/window manager clipboard (Gnome/Unity, KDE, etc.); depending on the selection method used (i.e. just highlighting, or an explicit Ctrl-C/right-click copy, etc.), the two clipboards may not be synchronized.

    • Thus, there are often issues when copying/pasting between GUI programs and the terminal.
  • The easiest solution if you have this problem is to use a tool that keeps both these separate clipboards in sync. I recommend ClipIt (sudo apt-get install clipit)

    • Start clipit (add to Startup Applications for convenience), and under Preferences, check both the Use Primary and Synchronize Clipboards options:

    enter image description here

share|improve this answer
1  
Wonderful, this is exactly what i needed –  Fawkes5 Jul 24 '12 at 22:26
2  
I prefer to disable clipboard synchronization because sometimes I want to copy something with Ctrl-C, select the text I want to replace and hit Ctrl-V. With clipboard synchronization what I would get is the same text I selected, not the one that I copied. –  jcollado Aug 1 '12 at 13:23
    
Give Parcellite a try --a lighter alternative of ClipIt –  pl1nk Aug 9 '12 at 15:34

There are actually 2 different kinds of copy & paste - there's the one provided by the underlying X11 graphics system, and there's the one provided by your window manager (Gnome, KDE, etc).

Highlighting text without clicking is enough to get it copied to the X11 buffer-space, and middle-clicking will paste out of that. If you use control-X or control-C, it will use the window-manager's buffer space as well (since you had to have highlighted it to use those keys), but only a control-V will get the text out of there - middle clicking won't.

To make things more confusing, window manager copy & paste will work with non-text items too, so even if your highlighting had gotten some text into both buffers, you might then have some files or complex data in the window-manager buffer instead and the two will be out of sync.

Some applications are smart enough to understand and use both, others aren't. Terminal windows are usually of the stupid variety when it comes to copy & paste. There are usually settings for each application to tell them how to fix the copy & paste mess, but getting them all set up correctly is a lot of work. Ubuntu gets most of them by default, I think.

The situation was historically much worse, and led to freedesktop defining standards around it:

http://standards.freedesktop.org/clipboards-spec/clipboards-latest.txt

share|improve this answer

Your Answer

 
discard

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.