Emacs Keybindings Everywhere!
Last updated: 17 Jan 2021
Are you accustomed to Emacs keybindings? You’ll find that your beloved Mac doesn’t give you complete Emacs keybindings.
Because Emacs keybindings on your Mac isn’t complete, it can be frustrating to even try using Emacs keybindings on it. Some keybindings work, some don’t!
To see this inconvenience and frustration in action, open Safari (I’m using Safari 14.0.2 on macOS 11.1). In Safari’s address bar (press
Cmd-l, that’s lower caps for ‘L’), which doubles as a search bar, type a simple sentence like “this is a sentence”. Moving forward/backward by 1 character works as per Emacs:
If you’re an Emacs keybindings user, you’ll likely have mapped your Caps Lock key to mean “Control key”. Just FYI. Official instructions to do that at here.
Now, try moving forward/backward by 1 word at a time. On Emacs, the keybinding is
Meta-b, respectively (where
Meta is your
alt/option key). Doesn’t work? The official Mac keybinding for that is
The Complete Mac Keybinding List
The first thing to do is to figure out the keybindings that come with your Mac. They’re specified in a
We’re looking for entries
(In case you’re not familiar with using the program
less, here’s a very nice guide for it.)
The next thing to do is to create some overrides. Create an empty file
~/Library/KeyBindings/DefaultKeyBinding.dict and paste this into it:
@ sign stands for
Cmd key. The official documentation is outdated/incomplete, as usual, so the full list of modifier keys are:
#: Numeric keypad
Did I miss out anything? Let me know if you need me to fill in more details! (I wrote this quick article because I found myself forgetting the lessons here and re-researching all these.)