Xcode: multiple key bindings per function

In Xcode I'd like the ability to set up several key bindings for the same function. For example, I'd like the step over function to be mapped to both F6 and F16. I don't see a way to do this from Xcode itself.

Does anyone know a way to do this? (I'm using Xcode 4.2.1)


Solution 1:

I researched a bit on your question. Natively it seems that there is no way to specify multiple shortcuts for the same function -- I've tried to open ~/Library/Prefences/com.apple.dt.Xcode.plist file and manually edit the NSUserKeyEquivalents adding a duplicate element for Step Over, but upon Xcode startup the duplicate element was automatically deleted (it makes sense since the wrapping element is named <dict>).

I've found a rough way to set the second shortcut, inspired by this article. Instructions are for OS X 10.8:

  1. in System Preferences, under Accessibility enable Enable access for assistive devices;
  2. download and install Quicksilver, a free launcher for OS X;
  3. save the following AppleScript to Documents folder (for example with name StepOver.scpt) -- be sure to copy also the ¬ characters. This scripts activates Xcode and selects the Step Over function.

    tell application "Xcode"
        activate
    end tell
    
    tell application "System Events" ¬
    to tell process "Xcode" ¬
    to click menu item "Step Over" ¬
    of menu "Debug" of menu item "Debug" ¬
    of menu "Product" of menu bar item "Product" ¬
    of menu bar 1
    
  4. launch QuickSilver and navigate to Preferences -> Triggers -> Custom triggers

  5. create a new trigger, in which you open StepOver.scpt script using the hot key you want (in the screenshot I've used F10). In the Scope tab you can specify that the trigger only works in Xcode. trigger example
  6. at this point the additional shortcut should work, I've built a basic console C++ application in Xcode and I could step over using using F6 (as "standard" shortcut) and F10 (as additional shortcut configured with QuickSilver).

As a final note, you could also evaluate software to create macros like Keyboard Maestro -- it's commercial and I haven't tried it.