Key Bindings is a feature of Mac OS X's Cocoa Text Input system that lets you bind text editing commands to keystrokes. The Key Bindings mechanism is responsible for causing the text behind the insertion point to be deleted when you hit the "delete" key, for example. However, there are tons of other functions that, if bound to reasonable keystrokes, can turn any Cocoa application's Text Input fields into full-on, keyboard-friendly text editors.
Take a look at Apple's hard-to-find introductory coverage of Text System Defaults and Key Bindings to get the general idea about Key Binding. Then see the NSResponder reference page, under the section "Action methods", for a list of all of the standard commands that can be bound to keystrokes.
Since switching from UNIX to Mac OS X, I've found myself automatically trying to use vi-like editing commands when entering text in text fields. Often, I'm more than slightly annoyed that they cause a beep, leave command turds in my text, or simply don't work. Key Bindings have helped me make OS X text fields feel a little more like vi, though.
Using the standard Input Manager, Text Input fields don't have modes like vi does, so you can't exactly duplicate vi to the degree I'd really like. For example, there's no Command Mode in which unmodified keys can move the cursor, delete text, et cetera; effectively, you are always in Insert Mode.
You can download my DefaultKeyBinding.dict
file and install it in your ~/Library/KeyBindings
directory
to get an idea of some of the things you can do with Key Bindings. Once
you've installed this file (creating the KeyBindings
directory inside your
Library
directory if it doesn't exist already), you'll need to
restart any Cocoa applications that you'd like to have take advantage of the
new bindings. The DefaultKeyBinding.dict
file is only read when
an application starts. Also, remember that only Cocoa applications use
this file; Carbon, Classic, and Plain Old Unix applications do not.
Here are the important entries from my DefaultKeyBinding.dict
file
(I recommend using /Developer/Applications/PropertyListEditor.app,
with "Show Strings in ASCII" selected, to create/edit your DefaultKeyBinding.dict
file):