Even though I've been using emacs for a very long time, sometimes even very basic features of the editor can remain unknown. It is both refreshing and annoying to discover that something that has made editing slightly annoying can be addressed simply and directly.
In my case, I have to confess that I didn't know about delete-selection-mode. (Am I still allowed to be part of the emacs club?)
delete-selection-mode is a minor mode that simply deletes the selected region of text if one starts typing something. This is how it generally works on Mac OS X (and probably other OSs as well): if I select a region of text, typing something will simply dump the selected region of text, insert what I just typed, and adjust the cursor accordingly. In emacs, for some reason, this is not, by default, how regions of text behave. By default, if one has a selected region of text and types something, the region is left unchanged, and the typed text is inserted wherever the cursor was. Normally, if one would want to delete a region (as opposed to kill it for possible future yanking), one would actually kill it, and simply not use the new text on the kill ring. The result is mildly uncomfortable: it's wasteful to cut text that one doesn't intend to paste.
But with delete-selection-mode turned on, one can simply hit DEL when there's a region of text to be deleted, and that text is genuinely delete (à la delete-region), and not put on the kill ring. And when one wants to simply overwrite a region of text, just start typing; there's no need to (wastefully) kill the region first, and then start typing.

0 comments:
Post a Comment