Skip to content

Instantly share code, notes, and snippets.

@highorderbit
Created March 16, 2011 04:03
Show Gist options
  • Save highorderbit/872002 to your computer and use it in GitHub Desktop.
Save highorderbit/872002 to your computer and use it in GitHub Desktop.
Example of an Xcode 4 binding that combines multiple keystrokes and multiple commands
<key>^x</key>
<dict>
<key>^i</key>
<array>
<string>selectWord:</string>
<string>enterSelection:</string>
<string>findNext:</string>
</array>
</dict>
@cahlbin
Copy link

cahlbin commented Apr 7, 2011

Did you manage to get this working properly in Xcode 4 (GM)? I can't seem to get multiple-key stroke bindings to work at all (used to work in Xcode 3.X)

@ybian
Copy link

ybian commented Jun 26, 2011

does not work either

@jad
Copy link

jad commented Jun 26, 2011

Unfortunately this doesn't work with Xcode 4. I've filed a bug with Apple that they've closed and marked as a dupe. Hopefully they'll fix it in an upcoming release. It's extremely frustrating to lose this behavior, though. And to make things even more strange, these bindings worked in all of the Xcode 4 developer previews up until DP6. Then suddenly all the key binding behavior went sideways and I had to re-add bindings one by one to figure out what worked and what didn't. It's stayed that way through the GM and remains that way in 4.0.1 or whatever the latest is.

Some multiple-key bindings do work, but not many. You can see some of the ones I've discovered in my current Xcode 4 key bindings file (scroll to the bottom). I've had to rather painstakingly add these one by one and figure out what it'll accept through trial-and-error.

@atommclain
Copy link

Check out my fork of jad's Xcode 4 key bindings file for a working example of two multi action bindings.

Caveat: I don't believe it's possible to safely or easily create unique multi action bindings. What I've surmised from my investigation of this issue, is that Xcode is comparing the users idekeybindings bindings against the StandardKeyBindings dictionary in /System. It appears that any binding that is not defined in StandardKeyBindings.dict is omitted. I haven't had a chance to test my hunch by directly editing StandardKeyBindings.dict but all my experimenting and testing leads me to believe that this is the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment