Archive for the Emacs Category

Emacs tip o’ the day!

Posted in Emacs, GNU/Linux with tags , on March 17, 2008 by Pete Daniels

This Emacs tip brought to you by Steve Yegge!

Make Emacs prefer backward-kill-word over Backspace

Emacs Wizards try to avoid hitting the backspace key, because it’s just remote enough from home-row to be annoying. We make typing mistakes all the time, but if you type faster than about 50 wpm, it’s more economical to kill the entire word and re-type it than to painstakingly backspace to your error.

Here’s what you add to your .emacs file:

(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)

Note that because Ctrl-w was already bound to kill-region, a very important command, you need to re-bind something else to kill-region. I chose Ctrl-x Ctrl-k (and its sloppiness-forgiving companion, Ctrl-c Ctrl-k), primarily because that’s the way they did it at my old company, which was filled with wise Emacs Wizards who taught me a lot of what I know. Rebinding Ctrl-x Ctrl-k means it’s no longer available for edit-kbd-macro, but you’ll use that infrequently enough that it’s not something you’ll miss having a shortcut for…

For a more in-depth look at this tip and how to use it effectively, and nine count ‘em nine more great Emacs tips, check out Stevey’s “Effective Emacs” post!