selections and cut-copy-paste: make it work like elsewhere

Most computer users today are used to a certain kind of behaviour when it comes to selecting text and cut/copy/paste:
  1. when I make a selection, I can see the select part with some different color;
  2. when I have selected some text, and I type something, it replaces the selection.
This is true for Windows, MacOS, GNOME, KDE and many other systems. But it's not necessarily true for emacs, although it seems that (1) has become the default for the yet-unreleased emacs version 23.

I prefer the behaviours (1) and (2) over the defaults. Fortunately, it's really easy to enable them by putting the following in your .emacs (see also the general discussion of modes):

(transient-mark-mode t)         ; make the current 'selection' visible
(delete-selection-mode t)       ; delete the selection area with a keypress
Normally, you can start a selection ('mark') with C-SPC (Ctrl-Space); the selection ('region') will be the area between this position and the cursor. However, transient-mark-mode also allows you to use the 'Windows-style' shift + arrow-key selections - at least in recent versions. I think these should be made the defaults, but defaults change only slowly in emacs-land.

Cutting text ('kill') can be done with C-w, and copying with M-w. After that, we can paste ('yank') the text with C-y. If you are used to Ctrl-X/Ctrl-C/Ctrl-V for cut/copy/paste, you could of course redefine these keys. However, especially Ctrl-X (C-x) is used in many places in emacs, and this would probably lead to tears.

However, there is cua-mode, which enables you to do that; it's smart in the sense that C-x works as 'Cut' in other systems, but it does not affect the normal usage of C-x in emacs. To enable cua-mode, add the following to your .emacs:

(cua-mode t)
Side-note: it's called 'cua-mode', because of the CUA-standard defined by IBM.

1 comment:

Joe Casadonte said...

There is an alternate CUA mode called CUA-Lite: http://www.emacswiki.org/emacs/CuaLightMode