About     Search     Feed

Nilesh D Kapadia


Music     Twitter     Github

Get Emacs-style keyboard shortcuts in Cocoa text widgets

Mac OS X already has defined some basic Emacs-style keyboard shortcuts (CTRL-N/P/B/F/K/Y/T/etc) which are available in Cocoa text widgets. But Cocoa is highly configurable, and allows for configuring a larger subset of Emacs-style keybindings (among many other possibilities).

These two references written by Jacob Rus are very useful for understanding what you can do with the Cocoa text system:

Customizing the Cocoa Text System
Customize the Cocoa text binding system

If you want to see my Emacs-style keybindings you can get it here. I did not enable incremental search yet as I couldn't get the input manager for it working yet.

Now this only gives you these keybindings when you're editing text in a Cocoa application. Non-Cocoa applications will not be affected. Firefox is not affected even though it uses Cocoa. It does appear to affect Java Swing apps, though, such as IntelliJ IDEA and Oracle SQL Developer, which both have Emacs keybindings that don't work properly until you make these changes (combinations such as Option-v output a special character otherwise, rather than performing M-v).

In a future entry I will talk about how to use Butler and Firemacs to give Firefox more Emacs-style text editing and keyboard shortcuts. Butler's ability to simulate keystrokes (and trigger on keyboard combinations) is pretty powerful.

© 2013 Nilesh D Kapadia