Awhile back I asked a question about custom key bindings in Xcode. I ended up recreating some of TextMate's key commands in Xcode. Just updated to Xcode 4 and it appears that the PBKeyBinding file no longer has any effect. What's the new hotness for custom key bindings, specifically for Xcode 4?
-
I've added a 100 point bounty to this question in hopes someone knows of any solution. I had started a similar question on AskDifferent... and, through the answer over there, I found my way here. http://apple.stackexchange.com/questions/22674/make-mac-os-x-option-arrow-work-like-windows-ctrl-arrow – Steve Aug 21 '11 at 00:20
5 Answers
Yes, it can be done (at least for the moment). After spending the better part of a day searching, experimenting and digging through the bowls of /Developer I finally figured out how to accomplish this.
Open IDETextKeyBindingsSet.plist
located in /Developer/Library/PrivateFrameworks/IDEKit.framework/Resources/
This bindings plist is formatted differently than others used throughout the system, the most important distinction is that all the methods must be listed in the same string, i.e.
<string>moveToBeginningOfParagraph:, insertText:, foo</string>
edit:
I have not tested this, but it looks like the new location in Xcode is
Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist

- 615
- 5
- 13
-
The fact that insertText: gets parsed like that is just damn wonderful!. This works in Xcode 5 too. Here is a binding for **inserting a doxygen comment:** `moveToBeginningOfParagraph:, insertText:, /*!, insertNewlineIgnoringFieldEditor:, insertNewlineIgnoringFieldEditor:, insertText:, */, moveUp:` I find that useful, and I have bound it to _cmd ctl 7_. – McUsr Feb 14 '14 at 06:33
-
It seems this folder has moved in Xcode 7. Any idea what the new location is, or if this still works? – Aaron Ash Feb 11 '16 at 21:17
You can use Keymando to create any keybinding you like in Xcode 4 and any other OSX application.

- 14,622
- 4
- 54
- 85

- 818
- 1
- 8
- 18
-
I've tried this app and it works as advertised. It's really neat. Exactly what I was looking for. – Steve Aug 25 '11 at 19:34
-
Marking this as the selected answer since it's the only workaround I've found! – typeoneerror Sep 11 '11 at 15:10
-
Does this let you string multiple key commands together? I quickly bought and then realized it might not be what I was hoping. --UPDATE-- It does! Just like this: only /Xcode/ do map '
', " – Bob Spryn Oct 17 '11 at 22:30" " " end
The answer now seems to be to use the idekeybindings
files — these are tied to the custom keyboard shortcut sets you create in the preferences — stored at ~/Library/Developer/Xcode/UserData/KeyBindings/
. More information can be found in the Key Bindings Preferences Help. However it sounds like people are having no luck trying to combine multiple actions under one keyboard shortcut (as you can do with the older-style key bindings dict files). But presumably you could still do this in If this doesn't work, I think you're out of luck for now. Sorry; file a bug!DefaultKeyBinding.dict
, as long as you don't mind the shortcut also working in other applications :)

- 115,675
- 35
- 233
- 266
-
2Unfortunately, key bindings in DefaultKeyBinding.dict have no affect on Xcode's editor. Xcode completely ignores these in favor of it's own key binding system. (a fact I know thanks to your answer on AskDifferent showing me how to do this, and supported by the thread referenced in the question: http://stackoverflow.com/questions/476953/xcode-delete-line-hot-key) You say: "people are having very little luck", but I found they haven't had any luck *at all* (http://stackoverflow.com/questions/5975026/xcode-4-idekeybindings-multiple-commands-for-one-keystroke). – Steve Aug 21 '11 at 03:40
-
Yep, I spent a few hours on these the other day. I thought I could define my own bindings in the idebindings, but idebindings is actually what the IDE *writes to* when you change the key commands in the preferences menu. I'm calling this problem WONTFIX as Apple just decided to remove custom key bindings and they are NOT obeying the system-wide bindings any longer. HMMPH!! – typeoneerror Aug 21 '11 at 21:22
-
-
Somewhat. But I haven't had the time to come up with a working demo yet (been slammed this week). There is a cool app on the Mac App Store called "Keymando" which, through a simple-to-construct Ruby script, allows you to create key bindings which work in Xcode. One of the "Built-In" features is it's ability to translate a single keystroke into multiple key-sends. I've verified the application works in Xcode 4... so I have high hopes that I can translate the single keystroke I want into the multiple keystrokes required to accomplish the task in Xcode. – Steve Aug 25 '11 at 19:32
-
Keybindings works perfectly well in Xcode 5, once you have gotten around to how to do it. Yes, there is the private keybindings file which resides at `/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist ` and you have to make both the file and the parent folder writable, which is quite easy through the info dialog of finder. And the format is as **atommclain** stated above, in a string. But from then on everything works splendily, with the same commands from NSResponder as we use in the DefaultKey.dict You must rebind keys after edit. – McUsr Feb 14 '14 at 06:43
Kike here http://www.codedojo.com/?p=580
you use this binding set
Download http://www.codedojo.com/files/MSVC_xcode_config.zip
unzip it and place MSVC.pbxkeys in YourUserName/Library/Developer/Xcode/userdata/keybindings
and rename it to msvc.idekeybindings
then from
Xcode -> preferences -> keybindings
just pick msvc
Go to Xcode 4 > Preferences > Key Bindings and fiddle with them all you like. :)

- 242,470
- 58
- 448
- 498
-
Yeah, I know of these. I'm asking specifically about creating your own key bindings like http://stackoverflow.com/questions/476953/xcode-delete-line-hot-key/478583#478583. These are predefined actions, not a list of actions that can be mapped to a key combo, right? – typeoneerror Apr 11 '11 at 20:49