8

I'm making changes to the default keybindings and getting some conflicts. Just unsure how I can unmap a keybinding that I don't need? I tried to hit delete on when selecting the shortcut in the list but to no avail.

P.S. I've tried double clicking the shortcut but no - button appears on the right.

John Mike
  • 1,895
  • 3
  • 17
  • 26

3 Answers3

7

How to delete a keybinding on Xcode ? (using version 9.3 of Xcode)

The first method is obviously the little - that sometimes appears when double-clicking a binding.

The second method is not so quick but (in my experience) just as efficient. (Here I am assuming you've got a personalised keybinding profile already. If you don't, create one. I'll call it Personal.)

  1. In Xcode: select the shortcut you want to remove and attribute it a random binding (even one that causes conflicts, you'll delete it in two minutes, you don't really care).
  2. Quit Xcode.
  3. Go to ~/Library/Developer/Xcode/UserData/KeyBindings/.
  4. Open the file personal.idekeybindings (it's a simple XML file, any decent text editor should be able to handle it).
  5. Find the shortcut you modified and want to delete by searching its name using command + F.

You should then find something looking like this (each dict corresponds to a modified shortcut):

<dict>
    <key>Action</key>
    <string>execute:</string>
    <key>Alternate</key>
    <string>NO</string>
    <key>CommandID</key>
    <string>Xcode.IDEPlaygroundEditor.CmdDefinition.Execute</string>
    <key>Group</key>
    <string>Editor Menu for Playground</string>
    <key>GroupID</key>
    <string>Xcode.IDEPegasusPlaygroundEditor.MenuDefinition.Editor</string>
    <key>GroupedAlternate</key>
    <string>NO</string>
    <key>Keyboard Shortcut</key>
    <string>^&lt;</string>
    <key>Navigation</key>
    <string>NO</string>
    <key>Title</key>
    <string>Execute Playground</string>
</dict>

Delete this part:

    <key>Keyboard Shortcut</key>
    <string>^&lt;</string>

Do that for each shortcut you want to remove and don't forget to save the file before closing it. Now open Xcode and check for the shortcut: the space for the keybinding should be empty.

jps
  • 20,041
  • 15
  • 75
  • 79
  • Worked great, I had to remap the copy command i.e. cmd-C but couldn't do it in the keybindings preference. I also want to add the keypad plus key but it only adds the "+" key which doesn't differentiate to shift =:( – mretondo Jul 31 '18 at 20:07
1

When you double click a key binding, you should see an icon with a minus all the way at the right end of the text box. Simply clicking that icon removes the binding.

tsiki
  • 1,638
  • 21
  • 34
  • 5
    In Xcode 9 it appears this option is gone for some key bindings at least – Pier Feb 03 '18 at 00:46
  • 1
    Hmm you're right, for most it works but some (eg. save) it doesn't seem to work. I haven't found a solution for that. – tsiki Apr 02 '18 at 12:53
  • @tsiki Yep, this issue still exists in Xcode 14.1. I cannot remove the binding of Save (which is pretty useless as Xcode pretty much always auto-saves), which is quite annoying! – Sébastien Dec 05 '22 at 15:10
  • There is no such icon, I just cannot remove the conflicting key binding - probably Xcode bug – Jiří Křivánek Jun 20 '23 at 07:38
1

Xcode has two kinds of key bindings: ones you can customize within Xcode Preferences and ones you have to customize through System Preferences. The latter kind don't show a "minus" button within Xcode Preferences. To edit these:

  1. Open System Preferences -> Keyboard -> Shortcuts
  2. Click "App Shortcuts" then "+"
  3. Choose "Xcode"
  4. Put in the name and desired shortcut

Voila!

Jonathan Berger
  • 1,043
  • 13
  • 17