Emacs Style Keybindings on macOS

Listen — it’s not that I don’t want to use Vim keybindings. I’ve done it before. They’re fun. It’s kind of like giving your text editor a manual transmission. The reason I’m not using them now is because I don’t want one way of working with text on my computer which works with my editor, and another way that works everywhere else.

Something I’m always surprised more developer-type people don’t seem to know about is that macOS has pretty good support for Emacs-style keybindings built in, and they pretty much work with every text field in the system.

Three that I use a lot are Control-A to go to the beginning of a line, Control-E to go to the end, and Control-K to cut to the end of the current line. You can even use Control-Y once you’ve done that to paste what you just cut.

Apple has a whole documentation page listing these, along with a ton of others, but here are a few of the Emacs-style ones I could pick out. This document really highlights something I always notice when using any operating system other than macOS, which is how much less consistent and extensive keyboard support seems to be on every other system.

Shortcut Function
Control-A Move to the beginning of the line or paragraph.
Control-E Move to the end of a line or paragraph.
Control-F Move one character forward.
Control-B Move one character backward.
Control-P Move up one line.
Control-N Move down one line.
Control-K Delete the text between the insertion point and the end of the line or paragraph.
Control-D Delete the character to the right of the insertion point. Or use Fn-Delete.
Control-H Delete the character to the left of the insertion point. Or use Delete.
Control-T Swap the character behind the insertion point with the character in front of the insertion point.
Control-O Insert a new line after the insertion point.
Control-L Center the cursor or selection in the visible area.
Control-U Clear the entire line before the cursor (in Terminal and some text fields).
Option-Delete Delete the word to the left of the insertion point.

Published by


Leave a comment