Wed Oct 18 20:58:05 CEST 2006

Keyboard copy and pasting

I don't remember if I have already mentionned that, but it is my life's goal to get rid of rats, mice and other rodents. For most everyday usage, mouse operation is at best impractical and cumbersome, and at worst totally braindamaged. Before you start flaming me, let me say that:

  • Yes, graphic applications that require 2D positionning are a valid use of the mouse (I'm thinking picture editing, PCB layout, stuff like that),
  • Paging through the drop-down menus of your favourite application does not make the mouse useful, it just makes drop-down menus brain damaged.

So, one of the last things I didn't know how to do only with my keyboard was cutting and pasting, mostly between Vim and Firefox's URL bar. I have to concede to the Windows people, X11's cutting and pasting is a mess. Here's how to do it.

First thing to understand is that X has 2 different buffers: the primary selection buffer (which corresponds directly to the text that is selected right now on the screen) and the clipboard, which is filled through active action (so to speak). Now the really fun part is that each application seems to have its own idea of how to handle the buffers, well in line with X's founding principle of providing mechanism and no policy.

Xterm only uses the selection buffer. You copy the buffer to Xterm with shift-insert (that's right).

Vim uses a register name for each: "* is the selection buffer, "+ is the clipboard.

Firefox is a bit confused: ctrl-L ctrl-C copies to the clipboard, while ctrl-L home shift-end ctrl-C copies to the primary selection (which seems just stupid).

So there. We just need to keep in mind what we're copying into, and we no longer need the mouse. That makes me happy.