Emacs keybindings on macOS

Posted on October 28, 2020

This has nothing to do with Haskell, but was too good not to share. Stumbled across this documentation for Cocoa that shows how to customize the keybindings across all Cocoa applications. Just create a file ~/Library/KeyBindings/DefaultKeyBinding.dict, here's an emacs example:

{
    /* Additional Emacs bindings */
    "~f" = "moveWordForward:";
    "~b" = "moveWordBackward:";
    "~<" = "moveToBeginningOfDocument:";
    "~>" = "moveToEndOfDocument:";
    "~v" = "pageUp:";
    "~d" = "deleteWordForward:";
    "~^h" = "deleteWordBackward:";
    "~\010" = "deleteWordBackward:";  /* Option-backspace */
    "~\177" = "deleteWordBackward:";  /* Option-delete */
}