Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
Invented by someone French.

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


                                                       

Copy and Swap

Swap Highlighted Text with Text on Clipboard
  (+21)(+21)(+21)
(+21)
  [vote for,
against]

As an alternative to Copy and Pasting text, I think it would be useful to have a 'Swap' function. Previously copied or cut text residing on the clipboard will replace the currently highlighted text and the currently highlighted text will replace the text on the clipboard.

Will make quick work for certain text maipulations.

blahginger, May 02 2001

(?) Clipboard managers http://www.davecentral.com/clipman.html
[angel, May 02 2001, last modified Oct 04 2004]

[link]






       [bookworm]: Uh... you can on every modern GUI I've seen. "Drag and drop text," it's called, and it was really big in 1990 or so. What are you using?   

       [blahginger]: What kind of text manipulations did you have in mind?
egnor, May 03 2001
  

       I think what [blahginger] wants is that when you highlight text in your document and hit <CTRL>V, the clipboard text appears in your doc, and the text that *was* in your doc goes to the clipboard. I can see the utility of it, and there are several applications which allow multiple clipboard texts (see link).
angel, May 03 2001
  

       what's wrong with find and replace? highlight 'new' text. <CTRL>C <CTRL>H Key original text <CTRL>V ....go .job done
anselda, May 03 2001
  

       Yes, [angel], I know what [blahginger] is proposing, but I want to know why. What's a use case? Describe a text editing scenario where you'd actually want to swap the clipboard with the selection. Depending on the intent, multiple clipboards and/or drag-and-drop text may or may not be suitable replacements.
egnor, May 03 2001
  

       Possible use: I have three ISP phone numbers in my PPP program. They are dialed in the order entered. Sometimes I need to dial in to the second one or the last one, and in those cases I need to get one of those numbers in the first slot and the first number in a subsequent slot. This would be perfect for that.
PotatoStew, May 03 2001
  

       Uh...   

       So you want to swap two pieces of text? Select the second one, *cut*, put the cursor before the first one, *paste*. Better yet, with drag-and-drop text, select the second one and drag it to just before the first.   

       How does this idea make it any easier? Do you see why I'm having trouble seeing why it's useful, now?
egnor, May 03 2001
  

       egnor: you are assuming that there is no text between the two chunks to be swapped. If I want to swap paragraphs 2 and 5 of a document then there are some extra steps involved beyond what you describe. If implemented properly, it's possible that this idea could save keystrokes or mouse activity.   

       It would need to do the swap right in the document, rather than in the clipboard to be most effective. Something like "highlight paragraph 5, ctrl-X, highlight paragraph 2, ctrl-shift-V pastes 5 in it's place and transfers 2 to wherever 5 used to be."
PotatoStew, May 03 2001
  

       I use highlight-drag more than anything else, but I can see where I'd use a swap command. Especially in my webpage, where I need to alphabetize, and sometimes goof.
StarChaser, May 04 2001
  

       Potato and waugs have the idea correct. The specific example that prompted me to submit the idea was a simple coding error where I mixed up the order of some variables. Granted that this idea would save really only one keystroke (Shift +Del) but it seems to happen to me often enough where I think I would use it. As for the keystroke I would guess (Ctrl+Del) ... I use the alternative Ctrl+Ins for Copy, Shift+Ins for paste and Shift+Del for Cut, so Ctrl +Del is the only thing left and I do not think it currently does anything special.
blahginger, May 04 2001
  

       This is a brilliant idea blaghinger.   

       (No, I'm not just happy that someone actually posted an idea...I really like this one)
iuvare, May 04 2001
  

       I'm a programmer and I see this as a great idea - even if half the people who have commented on it mis-understood what it is. This would be quite simple to code in most applications. Maybe Microsoft could build it into the standard command in the next version of Windows.
CasaLoco, May 04 2001
  

       engor: the idea was to swap the currently highlighted text with the clipboard. Although you do bring up an interesting point...the clipboard (or something) does seem to remember 'where' the currently cut text was cut from , otherwise 'undo' would not work. So theoretically it should be possible cut some text onto the clip board, highlight some other text and then issue a 'swap' command which will swap the highlighted text and the clipboard text and then actually put the new clipboard text back where the original highlighted text came from. (this isn't getting any less confusing is it?)   

       what I do not know is whether the 'undo' command undoes a specific command, or does it actually just revert the whole document back to a previously saved state.
blahginger, May 06 2001
  

       OK. The use case here is that you want to swap two non-adjacent blocks of text in a document. (I maintain this is rather rare, especially compared to swapping adjacent blocks of text, but whatever.)   

       With copy and paste, you need to select, *cut*, move, *paste*, select, *cut*, move, *paste*.   

       With your concept, you need to select, *cut*, move, select, *swap*, move, *paste*.   

       With the "accelerated" concept (it remembers where the clipboard came from), you need to select, *cut*, move, select, *hyperswap*.   

       With drag-and-drop text, you need to select, *drag-move*, select, *drag-move*   

       I'm not sure this is a huge win, especially in the absence of acceleration, which is getting a little strange since it relies on the presence of extra state. Anyway, undo is generally implemented not by saving the entire document (that would be prohibitively expensive for multi-level undo) but by keeping an "undo record" for each action that records how to, well, undo it.
egnor, May 06 2001
  

       How I see it, this command would only be used to exchange the two particles of text. This could be done with only "swap". You highlight the first particle, <CTRL>S or something, nothing happens, highlight the second one, <CTRL>S again, and they're swaped. Faster and easier then the "copy swap" command.
janko, May 06 2001
  

       Please:   

       Obviously "copy" is an improvement over "cut" alone, since it reduces down the number of operations required to perform common tasks.   

       In my annotation, I specifically listed the steps required for each version, and criticized the improvement as minor (at best) on that basis. I also criticize the frequency of the task, though if people tell me they frequently swap non-adjacent text chunks, I'll believe them.   

       (After all, we could dream up wacky macros for uncommon actions until the cows come home; something like this is only interesting if it would actually speed up a commonly performed operation.)   

       The "accelerated" version is "accelerated" because it's obviously faster than the other version (which is the original, because it's what the idea seems to describe). It doesn't really matter if the first operation is "cut" (as I described), "swap" (as [janko] described), or "copy" (as you described); the number and complexity of the operations are still the same.   

       (If this were actually implemented, it should probably be a "swap" operation, and the first chunk of text should turn a wacky color or something to indicate its status.)
egnor, May 07 2001
  

       blahginger, would you add an example to the idea? Clearly we differ on what we think you want to have automated.   

       What I often want to do, which is not quite what you describe, is convert   

       text:"foo zot zot zot bar"
buffer:"gum"
  

       to   

       text:"bar zot zot zot foo"
buffer:"gum"
  

       Emacs is the Way, although I've had interactive Word macros to do something like.
hello_c, May 09 2001
  

       I bet they look like garnut alboir sicomg...
globaltourniquet, May 09 2001
  

       I would kill for this feature. At least in Excel.
RayfordSteele, Feb 08 2002
  

       Two words: Office 2000.
phoenix, Feb 08 2002
  

       more M s to make it compy and swamp
technobadger, Feb 09 2002
  

       This is a good idea, I think I may bake it, albeit for a DTP program on a computer system I doubt many of you've ever heard of.
I like it because I often type something like 'A and B', then decide I want 'B and A'.
Loris, Aug 25 2002
  

       Here is a very common scenario:   

       Say, I wrote   

       myFunction(foo.getBar(stuff))   

       and now I want to change it to   

       bar = foo.getBar(stuff)   

       myFunction(bar)   

       if there was a "swap" key, I would add "bar" on the line above, copy it, go back to the original line, swap bar for foo.getBar(stuff), go back up and paste it after "=".
qaramazov, May 27 2003
  

       The biggest situations where I can see the 'non-accellerated' version of this being useful is when the selection operations can be more easily done before the paste than after, or when the sequence "paste/select/copy" would not be possible.   

       As an example of the first scenario, suppose that the person is moving single words around, and the clipboard happens to also contain a single word. Double-clicking a word will select it. The sequence "double-click first word; swap; double-click second word; swap; double-click original spot (now holds old clipboard text); swap" will swap two words while leaving the clipboard holding its former contents. The "swap" function means the old clipboard is preserved, but more signifcantly allows a click-drag selection to be replaced with a double-click selection.   

       The latter scenario can occur often in two types of application: (1) applications which have restricted-length fields; it may not be possible to paste the new data into a field without first removing the old data; (2) applications where a paste operation overwrites the destination instead of inserting into it. In some applications of these types, the swap function may be very handy indeed.
supercat, May 27 2003
  

       I often want this for dialog boxes (eg, swapping the to: and cc: fields). In this case the accelerated version would be no good.   

       But, as always, this problem is solvable with auto hot key. Here's a simple script that maps windows-v to "swap highlighted text with clipboard". It works everywhere I've wanted it.   

       #v::   

       AutoTrim Off   

       ClipboardOld = %ClipboardAll%   

       Send ^x   

       ClipboardNew = %ClipboardAll%   

       Clipboard = %ClipboardOld%   

       Send ^v   

       Clipboard = %ClipboardNew%   

       return
xorsyst, Mar 12 2010
  

       I'm about 9 years too late for this discussion but for readers with a train of though similar to egnor's, and who would like a succinct example of where it would be useful, I think I have one:   

       I am working in MS Excel. I have the word "Sales" in cell A1 and "$5,000,000" in cell B1. I want to swap them, to have "$5,000,000" in cell A1 and "Sales" in B1. The worksheet is protected, and I cannot make use of any cells other than A1 and B1.
DMc, Mar 19 2010
  

       I like the idea. I like drag and drop text, too... when I have a real mouse. This would be great on my laptop, on which I hate the mouse so much that, when using a word processor or spreadsheet application, I turn the trackpad off and use keyboard shortcuts.
BakedRiemannZeta, Mar 20 2010
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle