The Emacs navigation keys have been standard in OS X (for apps that respect the OS X text system) for many years, but Electron incompletely (or incorrectly) implemented them so that opt-f is word forward and opt-b is word back instead of ctrl-opt-f and ctrl-opt-b.
Electron ignores the navigation commands in the OS X text system, so they can’t be fixed or remapped with ~/Library/KeyBindings/DefaultKeyBinding.dict
. Interestingly, some commands in the text system (like insertText:
, insertNewline:
, cut:
etc.) are respected.
Ancient primitive macintoshes had cut/copy/paste on F2, F3, F4 — so for many years I’ve used ~/Library/KeyBindings/DefaultKeyBinding.dict
to keep that muscle memory, and that works fine in Electron apps.
The two apps I use most now are Obsidian and VSCode. VSCode is also Electron, but lets you customize virtually everything, so in VSCode I changed word forward to opt-f and word back to opt-b, along with the shift
counterparts for selecting, to match Obsidian so that I could (whose implementation I assume came from the stock Electron implementation).
Here’s a list of the standard Mac OS navigation shortcuts, that have been around since the Internet stone age, and came from NeXT via YellowBox/Cocoa but were based on EMacs:
"^a": "moveToBeginningOfParagraph:",
"^A": "moveToBeginningOfParagraphAndModifySelection:",
"^f": "moveForward:",
"^e": "moveToEndOfParagraph:",
"^E": "moveToEndOfParagraphAndModifySelection:",
"^k": "deleteToEndOfParagraph:",
"^F": "moveForwardAndModifySelection:",
"~^f": "moveWordForward:",
("~f" in Electron),
"~^F": "moveWordForwardAndModifySelection:",
("~F" in Electron),
"^d": "deleteForward:",
"^b": "moveBackward:",
"^B": "moveBackwardAndModifySelection:",
"~^b": "moveWordBackward:",
("~b" in Electron),
"~^B": "moveWordBackwardAndModifySelection:",
("~B" in Electron),
"^h": "deleteBackward:",
"^p": "moveUp:",
"^P": "moveUpAndModifySelection:",
"^n": "moveDown:",
"^N": "moveDownAndModifySelection:",
"^t": "transpose:",
"^v": "pageDown:",
"^V": "pageDownAndModifySelection:",
"^o": ["insertNewlineIgnoringFieldEditor:", "moveBackward:"]