cschleiden
Published on

Emacs keybindings on macOS

Authors

Recently set up a new Mac. Probably knew this when I got my previous one but forgot about it, so TIL again.

I like using simple Emacs keybindings for navigation. And while MacOS has great support out of the box, like Ctrl-A goes to the beginning of a line, Ctrl-E goes to the end, Option-F or Option-B does not navigate to the next or previous word but prints Ƒ or instead. Thanks a stackoverflow answer, the solution is quite simple:

Edit ~/Library/Keybindings/DefaultKeyBinding.dict and add:

{
    "~d" = "deleteWordForward:";
    "^w" = "deleteWordBackward:";
    "~f" = "moveWordForward:";
    "~b" = "moveWordBackward:";
}

Then restart all open apps.