Normalizing C-w Between Terminal And Emacs

Another quickie for those of you who prefer using Emacs in the terminal. The default Emacs action for Ctrl+w is to delete the current region. In most shells, Ctrl+w deletes the previous word.

Srijan Choudhary found this a little disconcerting so he ginned up a bit of Elisp that makes Ctrl+w delete the previous word in Emacs unless the a region is active in which case it deletes the region. That helps ease muscle memory problems between the shell and Emacs.

This is not a problem for me for two reasons. First, I hardly ever use the shell anymore. Almost everything I do is in Emacs. Even when I am in the shell, I hardly ever remember to use Ctrl+w. More importantly, I long ago installed Steve Purcell’s whole-line-or-region, which, among other things, kills the active region if there is one or the current line if not. It’s a great package that I use many times a days. It’s bound to Ctrl+w so I wouldn’t want to change it.

If this is a problem for you, take a look at Choudhary’s post for the Elisp to fix things up.

This entry was posted in General and tagged . Bookmark the permalink.