Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
add comment

migrated from stackoverflow.com Aug 31 '12 at 10:31

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
1  
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 work just as well without additional set-up code. –  Daniel Beck Dec 30 '12 at 20:08
    
Thanks @DanielBeck, I'm not familiar with AppleScript. I've edited my answer and simplified this part using with your suggestion -- now the code is more readable. –  edymtt Dec 30 '12 at 20:17
    
This works! It's a little complicated to set up, but only took about 2 minutes. I think I like Quicksilver as a tool I could use for a few other things. Thanks for figuring this out! –  joseph.hainline Dec 31 '12 at 2:57
add comment

You can use the keyboard shortcut mapper for this process see attached image.

enter image description here

I hope this helps you

share|improve this answer
    
I was so hopeful this would work! When I tried it, only the F16 keyboard shortcut worked, and F6 no longer worked from within XCode (it just made the error sound instead of doing anything). The system level mappings seem to overwrite the app level mappings. I'm using XCode 4.5.2 and OSX 10.8.2. Did this work for you, and what versions are you using? –  joseph.hainline Dec 18 '12 at 3:42
    
Hi there sorry it wasn't complete;y correct use ctrl+f6 this will work alongside f16 that is the best I think you can get my apologies. –  Justin Erswell Dec 18 '12 at 8:37
    
Thanks for the attempt, but I guess what I'm looking for is simply not possible. Ctrl+F6 is a different command than F6. When I map at the system level, it just overrides the app level. I'm really trying to get two keys mapped at the same time to the same function. –  joseph.hainline Dec 19 '12 at 3:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.