nullstream weblog - Xcode

Adding custom key bindings to Xcode

Xcode

February 21, 2009 02:34 AM PST

If you don't already have a custom Key Binding Set then this gives good info:
http://www.typeoneerror.com/custom-key-bindings-in-xcode-for-textmate-users/

And this is a reference of commands and keys.
http://www.erasetotheleft.com/post/mac-os-x-key-bindings/#comment-101

If you DO have a customer key binding set already like I do, then you have to use the Property List Editor to load your binding file:
~/Library/Application Support/Xcode/Key Bindings/*.pbxkeys
In the editor, select View > Show Strings as Non-lossy ASCII. Add your key bindings to the "text" dictionary. If you want more than one command bound to a key you need to create an Array with your keystroke. Expand the new key with the triangle on the side, then use the 'add Child' tool bar button to create a new child for each command. Or hit the + on the side for each new entry.

My move line macros (ctrl-shift+up arrow, ctrl-shift+down arrow):
^$\UF700
selectLine:
cut:
moveUp:
paste:
moveUp:

^$\UF701
selectLine:
cut:
moveDown:
paste:
moveUp:

These macros allow you to 'drag' lines up and down with the keyboard. The first link gives a kill line command and a duplicate line (which can also duplicate a multi-line selection).

(By the way I blame the need for these macros on Paul who hooked me on the habit of arranging my local variables by type length.)


Comments (8)