I have an Xcode window open with many tabs. I want to open a file through Quick Open (⇧⌘O).

When I decide to close the Quick Open menu and also close the current tab that I'm on, I'll press Esc to close the Quick Open menu, and then press ⌘W to close the tab. However, sometimes I make a mistake and press ⌘W on the Quick Open menu, which causes the entire Xcode window to close instead.

Is it possible to prevent this behaviour? Maybe prevent ⌘W from doing anything when Quick Open is open?

  • 1
    Oh yes, this is very annoying. Apr 24, 2018 at 14:20

3 Answers 3


Here's how you unset the keyboard binding for Close Tab aka +W.

  1. From Settings.app -> Keyboard -> Shortcuts -> App Shortcuts tap the + button
  2. From Application dropdown select Xcode
  3. Enter Close Tab for the Menu Title
  4. set any keyboard shortcut you like

enter image description here

This un-maps +W shortcut in Xcode app completely. After this you are free to remap the +W key bindings in Xcode.

In my case I like +W to close the document so from Xcode -> Preference -> Key Bindings I have these changes (In your case you can bind Ctrl + +W to Close Tab instead and leave Close Document unmapped).

enter image description here

  • If I understand the answer correctly, this means you're suggesting I use Ctrl+Command+W to close my Xcode tabs from now on?
    – peco
    Aug 23, 2018 at 3:51
  • Yes, or you can map it to any key combination you are comfortable with. Aug 30, 2018 at 12:08

The first thing that comes to mind is to change the default W behaviour in Xcode so that it doesn't close the entire Xcode window.

You can do this via Xcode > Preferences > Key Bindings.

It may be worth exploring all of the options there. One safe way to do that would be to create a duplicate of the Default Key Bindings set and modify that. More specifically:

  1. Launch Xcode
  2. Go to Xcode > Preferences > Key Bindings
  3. Click on the Key Bindings Set drop-down menu and select Manage Key Bindings...
  4. Now click on the plus (+) option at bottom left of the window
  5. Select the Duplicate "Default" option
  6. Give the set a name and click Done
  7. Now change the keyboard shortcuts you want and test whether you can get things to work as you'd like

Once you're happy you can exit Xcode preferences. This approach is safe because you can always return to your Default set whenever you want.

  • 1
    It's a good first place to look, but I don't think it has what I'm looking for. ⌘W's default behaviour is bound to "Close Tab" and not "Close Window", and Xcode prevents deleting the shortcut altogether and shows a message "Can't delete the keyboard shortcut because Close Window has alternate menu items".
    – peco
    Apr 25, 2018 at 3:14

Looks like this is solved with Xcode 11! ⌘W doesn't do anything when Quick Open is active now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .