Dealing with the Unix Copy and Paste Paradigm? 1125
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?"
Pasting urls (Score:5, Informative)
But i do feel your pain
Firefox and Konqueror should have a button for "Open the clipboard in a new tab".
Minor solution - Ctrl-K (Score:5, Informative)
Re:Common problem.. (Score:5, Informative)
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
Oh boy (Score:4, Informative)
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. [jwz.org]
-1 Redundant (Score:5, Informative)
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.
KDE klipper... (Score:5, Informative)
Or else, first paste what you want to insert, then delete what you want to remove...
Re:Common problem.. (Score:4, Informative)
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.
Re:Your proiblem... (Score:4, Informative)
Re:Common problem.. (Score:2, Informative)
no solution to a non-problem (Score:3, Informative)
So what is the problem? Are the apps you use broken?
Re:Pasting urls (Score:3, Informative)
Doesn't help the general problem though...
Clipboard Program (Score:3, Informative)
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.
Re:What middle button? (Score:2, Informative)
There are two clipboards, and highlighting should never clobber something you manually copied.
Re:Minor solution - Ctrl-K (Score:4, Informative)
Many of the bash control sequences do the same thing in web browsers. In most text editing situations, really.
Word of wisdom: emacs (Score:3, Informative)
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.
Re:What middle button? (Score:5, Informative)
http://freedesktop.org/Standards/clipboards-spe
X copy/paste (Score:5, Informative)
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 [freedesktop.org]
Re:Common problem.. (Score:3, Informative)
Everyone has it wrong all the time (Score:3, Informative)
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 [jwz.org] to the topic for more information.
I don't know what software you all are using... (Score:5, Informative)
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...
Re:Pasting urls (Score:5, Informative)
Agreed. While not a perfect solution, Clipboard Observer [sakura.ne.jp] may be a possible way of dealing with this. It can get really intrusive, though, because it can end up opening tabs when you're copying a link to paste somewhere else, like in e-mail or IM. Worth a try, though.
On an unrelated note, the same author also has Tabbrowser Extensions [sakura.ne.jp], basically some really, really, REALLY useful alterations to how Mozilla and Firefox handle tabs. With it, you can do things that should (IMHO) be in the codebase, like re-ordering tabs, moving tabs in groups, moving tabs between windows, opening duplicate tabs (complete with the tab's page history), and (my favorite) undoing the closing of a tab. I've been saved on a number of occasions by this last feature. Very handy. The author should be getting more recognition.
Re:Another Annoying Linux-Ism (Score:3, Informative)
setenv TERM ansi
then I always use the ansi terminal settings (i.e. backspace not Ctrl-H)tset
you are wrong (Score:3, Informative)
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.
Re:I prefer the X way, kind of... (Score:2, Informative)
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
Re:Common problem.. (Score:4, Informative)
Re:Pasting urls (Score:5, Informative)
Try middle-clicking in the main view area of mozilla/firefox with a URL in the clipboard...
Re:Common problem.. (Score:5, Informative)
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.
Re:Pasting urls (Score:5, Informative)
Re:X copy/paste (Score:3, Informative)
the "universal standard" (Score:5, Informative)
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..
Re:Common problem.. (Score:3, Informative)
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.
Re:Pasting urls (Score:5, Informative)
"Diggler is a small but powerful add-on for Mozilla, Netscape and Firefox. It adds a button next to the location bar which can clear the location bar..."
Similar, but without the keystrokes.
bash can use either emacs or vi ctrl keys (Score:3, Informative)
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
Re:What middle button? (Score:1, Informative)
Re:Common problem.. (Score:5, Informative)
Yeah, there's basically two clipboards.
Yup. The best explanation I know of how this works [jwz.org] from someone who would know :)
Re:Pasting urls (Score:3, Informative)
Yes, there *IS* a common clipboard standard! (Score:5, Informative)
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.
Excellent article on the subject (Score:5, Informative)
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 [freedesktop.org].
You didn't grew up for long... (Score:3, Informative)
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 ?
Re:Pasting urls (Score:4, Informative)
Re:Common problem.. (Score:3, Informative)
From the ICCCM [tronche.com], section 2.6.2 (referring to data transferred through selections): From a document explaining X selections [jwz.org]: By the way, "X-Windows" doesn't exist, it's the "X Window System", or "X" for short.
Re:If only Linux would get copy-paste right.. (Score:3, Informative)
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)
Re:Pasting urls (Score:3, Informative)
Unfortunately, it's so bug-ridden and terrible that Firefox developers won't accept bug reports from people who have it installed.
You've got it all wrong (Score:3, Informative)
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 [freedesktop.org] 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,
Re:Pasting urls (Score:3, Informative)
Double bonus, since... (Score:3, Informative)
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.
Re:bash can use either emacs or vi ctrl keys (Score:3, Informative)
Re:the "universal standard" (Score:5, Informative)
The first standardization, well before 1992, was the Macintosh Human Interface Guidelines published in Inside Macintosh around 1983-84. This is the origin of the Ctrl-C and Ctrl-V.
Apple did lots of usability studies for the Mac, and the fruits of this labor were the one-button mouse and the Command-z,x,c & v, as well as other standardized "Command Key Shortcuts."
This cluster of keys were selected because of their proximity to the Command key, and the ease of pressing them with the left thumb and index finger. Z, X, C, and V corresponded to Undo, Cut, Copy, and Paste, the most common operations that were required in a GUI-based work system. Others combinations were standardized for closing windows (Cmd-w), Saving (Cmd-s), Printing (Cmd-p), and Quitting programs (Cmd-q). All Mac programs had to include these functions and use these standardized shortcuts if applicable.
Sun used these same Command Key Shortcuts in OpenLook, and eventually Microsoft embraced and corrupted these combinations by replacing the Command key with the Control Key, which required using the left pinky finger instead of the thumb to press. The Alt key which is positioned in the same place as the Command key was already claimed in Windows for their pseudo-standard of activating menus based on the underlined letter. The Command Key Shortcuts outside of this cluster were partially implemented for printing and saving, but quitting programs or closing windows is still the archaic and unintuitive Alt-F4 on Windows.
-- Len
Re:Pasting urls - use Ctrl-L in Mozilla (Score:5, Informative)
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.
Stop blaming Linux! (Score:3, Informative)
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.
Re:Pasting urls (Score:2, Informative)
Also note that you can, within Firefox, drag a link or a selected URL text to the tab bar to open it. If you drag to an existing tab it will replace that tab, and on an empty area (or the X button, if the bar is full) of the tab bar it will open a new tab.
Re:Pasting urls (Score:5, Informative)
Your choice.
how it actually works: (Score:3, Informative)
Well, no, not really. Here's how it really works. [jwz.org]
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.
Re:If only Linux would get copy-paste right.. (Score:3, Informative)
Re:X copy/paste (Score:3, Informative)
klipper and ctrl-alt-v to save you from cb hell (Score:3, Informative)
If you use mozilla/firefox, another nice tip is to use the plug-in diggler [mozdev.org], 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.
Re:Pasting urls (Score:3, Informative)
I admit it's been a while since I used X regularly, but as I recall, you often didn't have a choice of which system to use -- many programs only responded to one or the other. This is what can be irksome. I distinctly remember some combination I had when I was running under XFce where I couldn't move a URL from the terminal window to Mozilla, period. Each of them knew about their own clipboard style, and that was it.
I admit I'm not sure what you mean when you say that the X windows system can "work across different terminal sessions whereas KDE/GNOME's cannot." If you simply had one unified clipboard, wouldn't this still be the case (if it was done correctly?) That's the way it works in OS X. This sounds like a problem with KDE/GNOME's implementation, unless I'm misunderstanding you.
Re:Pasting urls (Score:5, Informative)
Re:Pasting urls (Score:3, Informative)
in emacs... (Score:4, Informative)
Re:Pasting urls (Score:5, Informative)
Here's something close... (Score:2, Informative)
$ 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.
Re:Pasting urls (Score:2, Informative)
redirect the output to a file.
switch to the other terminal
read back from the file. use grep if necessary.
Re:Pasting urls (Score:2, Informative)
http://white.sakura.ne.jp/~piro/xul/_tabextension
the "universal standard" still works (Score:2, Informative)
By the way, Cut is Shift-Delete
Re:Pasting urls (Score:4, Informative)
Re:Pasting urls (Score:3, Informative)
It just so happens that most Linux distributions that I've seen come with a console-mode copy and paste program called "gpm". Look at the output of "ps" and see if it's running. If not, start it. Once it's running, switch to a virtual console and move your mouse and you should see a cursor floating around.
Re:Pasting urls (Score:3, Informative)
Ade_
Re:Pasting urls - use Ctrl-L in Mozilla (Score:3, Informative)
Re:Pasting urls (Score:3, Informative)
Go to about:config and set the value of middlemouse.contentLoadURL to false
I felt a whole lot better afterwards.
my notes (Score:3, Informative)
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)).
Re:Missing the real story (Score:3, Informative)
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.