Dealing with the Unix Copy and Paste Paradigm?
MolecularBear asks: "I grew up on Windows machines, using the ol' ctrl-c to copy and ctrl-v to paste. For the past few years I've been a hardcore Linux user, running it almost exclusively at home and at work. As I am sure you are all aware, highlighting text in Linux automatically performs a copy while the middle mouse button performs a paste. The Ctrl-c, Ctrl-v standard works in many applications, but not all. Lately I have begun to find the automatic highlight-copy to be annoying. As in, I'll highlight text to copy it, then realize I want to highlight a block of text for the purpose of deleting it. Of course, the second highlighting overwrites the first highlighting. I am curious about how other people accomplish their copy/paste needs. Any special setups, applications, or words of wisdom?"
I usually find you can just pick up the url by selecting it, then middle button drop it into the browser. That seems to work on konq, netscape, mozilla and firefox on both linux and solaris.
:)
But i do feel your pain
Firefox and Konqueror should have a button for "Open the clipboard in a new tab".
Just a small shortcut - Ctrl-K will (should!) erase the rest of the line, no need for highlighting it. Works wonders for clearing the URL bar :-).
Whats more interesting is that sometimes what control+v pastes is different from what the middle-click pastes.
.. cough xchat cough). It's extremely hard to convince egotistical programmers that their clipboard behaviour is actually wrong and confusing to users.
Yeah, there's basically two clipboards. The one when you just highlight something, and the one where you click "copy" in the menu.
The confusion comes when bugs in some programs confuse the two (or only implement one of them
I've had enough abrasive sigs. Kittens are cute and fuzzy.
Soon Slashdot will be filled with the waring camps of "X is perfection" and "X is old, so it is bad."
In this case, I find that it's merely a matter of getting used to the way the X clipboard functions. For example, delete the old text AFTER you paste the new text. It's a different way of managing your clipboard, but it's not necessary any better; for most jobs, I find it to be MORE convenient, and I start to forget to Ctrl-C when I'm in Windows.
For more information on how X handles the clipboard/selection, see Jamie Zawinski's informative web page.
It's always been broken.
And any mention of a possible solution brings down the wrath of nerds who want to keep unix as unintuitive and awkward as possible.
Besides the nuisance of what mouse click or keystroke you use to move text, it's not a clipboard like Windows uses, merely a text buffer.
Ie; it's only good for text. You cant copy/paste (and by extension drag and drop) files, bitmaps, etc uniformly between apps.
It's just another item in a laundry list of issues that are major to end users, but a low priority for hackers. Another speedbump on the road to Linux (unix) as a truly competitive desktop platform.
I don't need no instructions to know how to rock!!!!
Or else, first paste what you want to insert, then delete what you want to remove...
The difference between the select/middle-click paste and the Control-C/Control-V paste is because they each use different Clipboards. For instance if you are using KDE, The Control-C will copy to the KDE clipboard and the select with mouse will copy to the X-Windows clipboard.
I think the reason for the two different Clipboards is because the KDE (Or gnome? Not sure if it works the same way) clipboard handles copying content other than plain text and the X-Windows one not.
You can just click the middle button anywhere on the page. It'll do a paste of the buffer and load the url in it. You don't have to paste it into the url bar. Once you've done it a few times it makes life a lot easier. It's a far larger target to paste into. Just be careful not to click when you're hovering over a link.
You can press ctrl+l in firefox and it will take you to the address bar while simultaneously highlighting it. Since you didn't manually highlight it, it doesn't copy into the paste buffer, and you're free to paste the other URL you had in the buffer into the address bar.
So what is the problem? Are the apps you use broken?
Sticking feathers up your butt does not make you a chicken - Tyler Durden
The problem is X leaves copy/paste (and pretty much everything else) up to the application, and every application does it differently. Ideally one day we will all settle on a widget toolkit that enforces a standard copy/paste behavior. I'm not holding my breath though.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
If highlight clobbers something you copied with ctrl-c, then it's a bug in the program.
There are two clipboards, and highlighting should never clobber something you manually copied.
I've had enough abrasive sigs. Kittens are cute and fuzzy.
The more you use it, the more you use it.
Out of the box, it might not do much of anything you want, but few problems you can envision haven't been solved.
Only thing I haven't seen yet is a PalmOS version, so I can run it on my Kyocera7135. Got one of those external keyboards; but, hey, that's motivation to figure out how to configure a GCC cross-compiler and add something to the emacs canon.
Other than PalmOS, emacs is OS and window-manager (if any) agnostic, and comes with a ridiculous menu of existing tools.
Go, emacs.
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
Only if your application sucks. freedesktop.org spells out how this should work; ctrl-c/ctrl-v manage the CLIPBOARD selection, and mouse selection manages the PRIMARY selection. Selecting text with the mouse should NOT interfere with ctrl-c ctrl-v operations in ANY way.
c /c lipboards.txt
http://freedesktop.org/Standards/clipboards-spe
The current consensus on freedesktop.org is something along the lines of:
The problem is that some apps use only the primary selection for all copy/paste operations, so it can get confusing.
For more info, look here
In GNOME, at least, i think there's a separate clipboard that's for Ctrl+C and Ctrl+V, so if you use those two, you can use normal windows-styl C&P
The X clipboard work exactly like the Windows and Mac ones. When you chose 'copy' on an edit menu or similar (ctrl+c in a lot of toolkits) the application will claim ownership of the clipboard and copy the text to some internal buffer. When an application gets a paste in some way (edit->paste or ctrl+v perhaps) it will request the text from the clipboard owner.
There is ALSO the selection mechanism. Whenever you select text in an application it will claim ownership of the primary selection, whenever an application receives a middle mouse click it will request the primary selection from the registered application.
These two mechanisms are orhogonal and should in no way interfere with each other in a correctly written application. Hope this clears things up. See JWZ's small guide to the topic for more information.
In every program I use in Linux (specifically, Mozilla, rdesktop, and various GNOME stuff) Ctrl-C/Ctrl-V work perfectly, and so does the select/middleclick system, and neither interferes with each other.
I haven't used KDE in a long time but I understand that they introduced the same behavior with Qt3/KDE3.
Unless you're using really ancient software, pretty much everything will work in *either* mode, or you can do what I do and use a combination of both (choosing whether to bother pressing Ctrl-C to copy depending on whether you're going to need to highlight something at the destination).
I'm really curious to understand how so many people manage to still have a problem with this. Are you perhaps expecting that since "everybody knows that select copies on Linux", Ctrl-V will paste the thing that you last selected, instead of the last thing you Ctrl-C'd, and not testing it to verify this? Or just assuming that selecting something will overwrite your Ctrl-C buffer? I'd like to believe that people would actually test these things before posting Ask Slashdots about it, but you have to wonder...
setenv TERM ansi
then I always use the ansi terminal settings (i.e. backspace not Ctrl-H)tset
Speak for yourself.
There are tons of SDKs for X-Windows, almost all of them using a separate clipboard implementation/mechanism.
2. The above is completely false. X has a primary and secondary copy/paste buffer. It always works the same way, the only real caveat being that apps can use different key combos to control the primary buffer. I haven't used an app in years that used anything other than control+c/v for the primary buffer.
Sticking feathers up your butt does not make you a chicken - Tyler Durden
But I do know what you're talking about. I mostly run into this issue when entering text into the address bar of Mozilla. Fortunately, Mozilla uses emacs-style keybindings, so if I want to replace what's in the address bar with what's on the clipboard, I just:
:).
Wow, stop there! That sounds way too complicated. You do know that in Mozilla (as with Mozilla Firefox) you can just middle click anywhere on the current page and the browser will go to what's in the clipboard (or search Google with "I'm feeling lucky" if it's not a URL). Simplicity
"Madness is something rare in individuals - but in groups, parties, peoples, ages it is the rule." -- Nietzsche
Don't forget that shift-insert is almost always used to paste the X clipboard (as opposed to the ctrl-c/ctrl-v one managed by the desktop environment). But then some programs (gecko browsers being the most annoying for me) go and alias this to the functionality of ctrl-v, so I have no keyboard equivalent for middle-click paste.
Do you really need reason for beer? Wingman Brewers
Urr, all wrong.
Control-C/V will copy/paste the CLIPBOARD selection. Highlight/middle click will copy/paste the PRIMARY selection. No real applications use the SECONDAY selection, but it still exists.
There is no difference between any of these clipboards, GNOME and KDE don't have their own clipboards (though KDE does have a daemon to collect copied data so that it persists after the application closes), and all X clipboards can handle any content type: it's the applications which don't support it.
http://freedesktop.org/Standards/ClipboardsWiki is an excellent summary of the X clipboard.
Is supposed to be the original Windows copy/cut/paste buttons:
Copy: Ctrl-Insert
Paste: Shift-Insert
(I can't remember what Cut is, I never use it.. probably ctrl-delete)
Then, sometime in the Win95 or Win98 era, Microsoft changed it to the less-intuitive and less-standard Ctrl-C, Ctrl-V.
And Microsoft was a member of the body of people/organizations that made Ctrl-Insert and Shift-Insert the standard.. then went and trashed it...
This is the CUA92 user interface universal standard, by the way.. and i'm a bit busy right now to do a google search for it, but I'm sure anyone interested could find it..
"Champagne for my real friends - and real pain for my sham friends!" http://ericblade.postalboard.com/
This annoyed the hell out of me too, until I realized that ctrl-L will highlight the current url *without* overwriting your other highlighted text. Then hit delete or backspace to clear the url bar, and middle-click to paste in the new url.
At least, Mozilla on FreeBSD in X with WindowMaker does this. I can't claim it works on any other combo, which in itself is a discussion for another day.
I browse Slashdot at +3, Funny
Actually that's an Emacs control sequence.
Bash uses emacs control sequences by default, but can easily be set with either of 2 ways...
1. set environment variable EDITOR=vi
2. at prompt, type: set -o vi
then bash will act just like vi
no comment
You do know that CTRL+C is used to interrupt programs.. right?
Yeah, there's basically two clipboards.
Yup. The best explanation I know of how this works from someone who would know :)
Do you even know anything about perl? -- AC Replying to Tom Christiansen post.
Yes, there is a common clipboard mechanism. Once you understand that there are two separate clipboards (and that this is a feature), everything makes sense.
l - sp ec/clipboards.txt
Here's how it behaves in modern X environments like KDE 3, GNOME, XFCE, etc.:
- There is a clipboard (called CLIPBOARD in the specs), which you interact with by explicit copy and paste commands, for which the key bindings are conventionally Ctrl+C, Ctrl+V, Ctrl+X to copy, paste and cut respectively. Use it whenever you would use the Windows or Mac OS clipboard, teach it to new users, and so on.
- As an extra "easter egg", applications can manipulate the selection (the currently highlighted text) using the same API. The convention is to select text by dragging (or Shift+cursor keys, etc.) and to copy the selection from another program by pressing the middle mouse button. I will reassert: this is an "easter egg" for advanced users. The specs call this the "primary selection", PRIMARY (there is also a SECONDARY, but I am not aware of any program that uses it).
As documented here:
http://www.jwz.org/doc/x-cut-and-paste.htm
http://pdx.freedesktop.org/Standards/clipboards
OK, now the holes in that logical explanation:
- KDE 2 used to use Ctrl+C, Ctrl+V to manipulate PRIMARY. This was wrong and had all the flaws the poster cites. Solution: Upgrade to KDE 3, problem solved.
- Some other broken apps do the same. Solution: either fix them as you suggest, or stop using them. GNU Emacs 20 was apparently broken in the same way as KDE 2, while XEmacs and GNU Emacs 21 apparently work in the same way as KDE 3 (I can't confirm this, I use vim myself).
- Some (usually older) apps (like xterm) don't have copy or paste commands at all, but do have the selection/middle-click behaviour. Solution: either use something else (e.g. Konsole if you're a KDE fan) or learn the middle-click behaviour too. Since the command line is generally considered to be "hard", it shouldn't be that much of an intellectual leap.
- Ctrl+C already means something very common and specific (send a SIGINT) in console windows, so the standard Windows-style keybindings cannot be used in console windows. This is a historical clash between the Unix/DOS "Ctrl+C interrupts" and the Windows/OS2 "Ctrl+C copies" (on the Mac the convention is actually Command-C, so Ctrl is still available, and OS X's Terminal uses it as you'd expect) - Windows' MS-DOS-derived command prompt has the same conflict and a similar solution.
In a nutshell, there are TWO completely different clipboards implemented in X:
These two clipboards do not affect or interact with each other.
Other OS's (like Windows) only have the second kind. Modern Unix applications (like anything based on GTK, QT, or Mozilla) support both clipboards simultaneously and independently.
Old X Windows applications like XTerm only support the first kind. This is why you can't copy from or paste into an XTerm using C-c and C-v.
So if you are using modern applications, you should always be able to use C-c and C-v. If you have to copy or paste something into an XTerm, you will have to select it and middle-click. The solution is to use a moderm terminal, like gnome-terminal, instead of XTerm.
If you read the article, you'll learn that there are actually three different clipboards in X (one of which is never used), and that Emacs and XEmacs then implement yet another fourth clipboard!
Also see the freedesktop.org reference.
Those are not old. Those are a copy of Cmd-C Cmd-V from the Mac.
The original old shortcuts for Microsoft Windows are Ctrl+Ins and Shift+Ins. And when I'm on a Microsoft Windows station, my fingers are doing them without me thinking. But alas, less and less application support them, nowadays.
If Microsoft managed to change, in the course of a few years, such a fundamental characteristic of the UI, why X could not ?
From the ICCCM, section 2.6.2 (referring to data transferred through selections): From a document explaining X selections: By the way, "X-Windows" doesn't exist, it's the "X Window System", or "X" for short.
X can copy content and it has multiple clipboards, the problem is that everyone has done the implementation the wrong way. (See the links folks have posted above)
Gnome seems to be able to copy an paste files just fine, and I'm sure KDE can too. I use Blackbox and I can drag images off the web from Firefox to GIMP and they open (oddly enough if I drag from Firefox to Nautilis they save only the URL, probably a bug in Nautilus)
The Anti-Blog
This is a common mistake. In reality:
/they are broken/. Don't blame *nix, or X, blame the author of the app. Some apps are deliberately broken (because it makes More Sense[tm]) but not terribly many.
Highlighting text puts it into the X selection buffer.
Middle clicking pastes the X selection buffer.
CTRL+C (or whatever copy is set to) puts text onto the X clipboard.
CTRL+V (or whatever) pastes the X clipboard.
Notice: THERE ARE TWO BUFFERS. The X selection buffer and the X clipboard buffer. If your app overwrites the clipboard on highlight then it s misbehaving (see fd.o for what is "right").
Adjust your thinking just a smidge: When you select, it does not copy. It acts just like in Windows... only you can also access the last selection on a way Windows prevents.
Repeat: If your apps do not behave this way,
I want my Cowboyneal
sites like slashdot, sa and 2/4chan people will purposefully not create clickable links, but type the URL-as-text. Just select, CTRL+N, middle click, no problem.
The only thing that gets you is slashdot's page-widening-defeating mechanism. But you still have a chance to correct the typos in the URL bar if it 404s on you.
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
In Mozilla and Firebird at least there is the very useful, but little-known shortcut Ctrl-L. This highlights the url bar but does *not* copy it to the clipboard. So when I'm in that situation I do Ctrl-L, delete, middle click.
Of course, the middle-click on the page body works too, as long as you don't have to edit the URL. Ctrl-L is still super-handy if you want to type in an URL by hand or something.
You know what I hate? Wait, what do you like? I hate that!
I can't believe this is still an issue! I can't think of a single Linux app that I still use regularly that doesn't support Windows-and-Mac-style copy and paste. I just copied some text from OpenOffice to Mozilla to Konsole, no problem. The GNOME and KDE folks agreed on a common clipboard standard years ago, and probably 90% of popular Linux desktop apps conform.
Complaining because some free Linux apps still don't support the clipboard is like complaining that the Windows clipboard is broken because some freeware text editor doesn't copy and paste between programs.
Well, no, not really. Here's how it really works.
I totally agree that too few Unix programs support the C-c/C-v idiom, but it's orthogonal to the select/middle-click idiom.
Yes, there is a solution. It's called KDE and has implemented what you wanted since KDE 3.0. If you don't like the old X way of copy/paste, then don't use it. Use a modern desktop environment, they all provide copy/paste functionality you are used to.
If you use mozilla/firefox, another nice tip is to use the plug-in diggler, it adds a cancel button beside the browser url location field. You can then just press it to clean the field, instead of selecting and pressing del, this way the selection won't go to the clipboard.
I have solved the problem in Emacs with a customization package: it defines Apple-C and Apple-V, because I found it too annoying on my Mac. It also doesn't put marked text automatically into the clipboard (or whatever the emacs folks call it: kill-ring). you can get a package here.
First 2 shell scripts:
.bbkeysrc:
$ cat xcopy
#!/bin/sh
xclip -o -selection primary | xclip -selection clipboard
$ cat xpaste
#!/bin/sh
xclip -o -selection clipboard | xclip -selection primary
Then using your favorite keymapper set these to something close (M-c/M-v in my case). Here's an excerpt from my
KeyToGrab(c), WithModifier(Mod1), WithAction(ExecCommand), DoThis(~/bin/xcopy)
KeyToGrab(v), WithModifier(Mod1), WithAction(ExecCommand), DoThis(~/bin/xpaste)
Now alt-c copies highlighted text to the clipboard. Then alt-v copies the clipboard to the primary selection (so middle click them pastes it).
Note that many programs that support C-c/C-v use X's clipboard selection. That means you can hit C-c in say firefox, them hit C-v, then middle click into an xterm and get the text you copied from firefox.
Hope this helps.
"It is better to die on one's feet than to live on one's knees." - Albert Camus
Generally speaking, these still work. I got used to them and still use them regularly today in virtually all Windows applications.
By the way, Cut is Shift-Delete
Have you tried turning it off and on again?
Cmd-L works in Safari too (as you might expect, since it and Konqueror are practically identical at times).
"This is why men never share their feelings; because women always remember." -Just Shoot Me.
X' clipboard confused my when I started so I made these notes:
X has 2 clipboards. There is a selection buffer which is updated
automatically when you select any text. You can paste from this
buffer by clicking the middle mouse button.
Then there is the clipboard (which can be managed using
the xclipboard utility), which works like the windows equivalent
(Ctrl+Insert or Ctrl+c for copy, and Shift+Insert or Ctrl+v for paste)
Note gnome-terminal uses Shift+Ctrl+c and Shift+Ctrl+v instead.
Note when you copy something in an X application
and you close it, the content of the clipboard and selection
buffer is lost (unless you use an external app to manage the
clipboard (like xclipboard)).
X supports a similar method known as "content negotiation" whereby the programs decide between themselves on a compatible format for the data being moved.
I just selected some HTML text, including a hyperlink, from Mozilla, middle-clicked in a GAIM window to send it to a friend and it showed up perfectly formatted, with an active hyperlink in it.
If you want clipboard history / multiple clipboards, you have to use a third-party tool to do it, same as in Windows. It's called XClipboard.
In post-9/11 America, the CIA interrogates YOU!