DefaultKeyBinding.dict
The ~/Library/KeyBindings/DefaultKeyBinding.dict file lets you define your own key bindings in Mac OS X. It can be in one of two formats: old-style NeXT format (example) or modern-style XML plist format (example).
Rebinding ⌘+⌫
I wanted to rebind command-backspace (⌘+⌫) to deleteWordBackward:, and I got some help over in this AskDifferent thread. It was suggested that I use this as my DefaultKeyBinding.dict file:
/* my keybindings */
{
"@\U007F" = "deleteWordBackward:"; /* delete backwards one word */
}
This advice worked (thanks, guys!), but I already have a working DefaultKeybinding.dict in the XML format, so I wanted to try to get it working that way. I first added just this text near the bottom of my existing file:
<key>@\U007F</key>
<string>deleteWordBackward:</string>
And I also tried creating a brand-new XML-formatted file with just the ⌘+⌫ entry:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>@\U007F</key>
<string>deleteWordBackward:</string>
</dict>
</plist>
But neither files worked. The apparent situation, then, is that you can rebind ⌘+⌫ only in the old-style NeXT format, and not in the XML plist format. My questions are:
- Is this accurate, or should the syntax change somehow when I'm switching to XML format?
- Will I regret moving the rest of my
DefaultKeyBinding.dictfile over to the old syntax? It wouldn't be much work to do so - it's only one or two dozen entries - but I'm not sure if the old style is deprecated or ill-advised for some other reason.
Edit: Original DefaultKeyBinding.dict
Someone requested information on my original file in the comments, so I figure I might as well include the whole thing here.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key></key>
<string>complete:</string>
<key>^ </key>
<string>setMark:</string>
<key>^a</key>
<string>moveToBeginningOfLine:</string>
<key>^e</key>
<string>moveToEndOfLine:</string>
<key>^j</key>
<string>setMark:</string>
<key>^v</key>
<string>pageDown:</string>
<key>^w</key>
<string>deleteToMark:</string>
<key>^x</key>
<dict>
<key>^m</key>
<string>selectToMark:</string>
<key>^x</key>
<string>swapWithMark:</string>
</dict>
<key>~</key>
<string>deleteWordBackward:</string>
<key>~<</key>
<string>moveToBeginningOfDocument:</string>
<key>~></key>
<string>moveToEndOfDocument:</string>
<key>~^h</key>
<string>deleteWordBackward:</string>
<key>~b</key>
<string>moveWordBackward:</string>
<key>~d</key>
<string>deleteWordForward:</string>
<key>~f</key>
<string>moveWordForward:</string>
<key>~n</key>
<string>scrollLineDown:</string>
<key>~p</key>
<string>scrollLineUp:</string>
<key>~v</key>
<string>pageUp:</string>
<key>~</key>
<string>deleteWordBackward:</string>
</dict>
</plist>

~for option or$for shift? – conorgriffin Sep 14 '11 at 22:35^for control? – conorgriffin Sep 14 '11 at 22:50~and^, but none with$or@. (Note: I went ahead and added my original DefaultKeyBindings.dict file to the OP as well in case that turns out to be useful.) – Micah R Ledbetter Sep 14 '11 at 23:13@is not accepted in the XML style of plist file. It doesn't make much sense but I can't find anything more about it. – conorgriffin Sep 14 '11 at 23:31