Custom key bindings Xcode 4?

2019-02-03 14:43发布

问题:

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?

回答1:

You can use Keymando to create any keybinding you like in Xcode 4 and any other OSX application.



回答2:

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



回答3:

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 DefaultKeyBinding.dict, as long as you don't mind the shortcut also working in other applications :) If this doesn't work, I think you're out of luck for now. Sorry; file a bug!



回答4:

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



回答5:

Go to Xcode 4 > Preferences > Key Bindings and fiddle with them all you like. :)