Adding C-DEL To The macOS Keybindings

One of the little known but great features of macOS is their support of Emacs keybindings. Although most people don’t know it, this support comes in two parts. The first is that some of the common Emacs bindings such as Ctrl+a, Meta+b, and similar motion commands are defined by default and work in all macOS apps.

Less well known is that macOS allows you to install your own bindings for all their editing commands. In particular, you can install many of the common Emacs editing commands so that you can leverage your Emacs muscle memory with all the apps on your Mac.

I write about this periodically—last time here—when I see an Emacs user discover macOS’s rudimentary support for Emacs motion commands. But this post is not one of my periodic reminders. Rather, it about a missing binding and how easy it is to edit the extended bindings.

For as long as I can remember, I have used both Ctrl+Delete and Meta+Delete to delete the previous word in the manner recommended by Steve Yegge. Most of the time, it’s more convenient to use Ctrl+Delete for this but, sadly, that’s not supported by the DefaultKeyBinding.dict that I recommended.

Happily, it’s easy to add the desired binding. Here’s the new entry:

"^\U007F"   = "deleteWordBackward:";            /* C-DEL        Delete word backward */

Just add it to DefaultKeyBinding.dict and restart macOS to have it take effect. Pay particular attention to the punctuation after deleteWordBackward. It’s fussy and easy to get wrong.

This is a small thing and maybe nobody but me cares but it has made my life a little bit easier. As usual with these things, I wonder why it took me so long.

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