citykid
citykid

Reputation: 11112

How to prevent Visual Studio Code from exiting when pressing Ctrl+W and no editor is open

Pressing Ctrl+W closes the active editor window. When no more editors are open, Ctrl+W terminates VSCode. Could not find a related setting.

To me this is unexpected. Is it easy to prevent this?

Just realized that Ctrl+W is "close Window" while Ctrl+F4 is "close editor". Maybe I should just use the close editor command.

Upvotes: 8

Views: 1006

Answers (2)

David Cruwys
David Cruwys

Reputation: 6862

I had this issue on a new VSCode install today and was having troubles with the suggested answers I have seen.

Ultimately this was my solution

~/Library/Application Support/Code/User/settings.json

"window.closeWhenEmpty": false

Upvotes: 4

Alex
Alex

Reputation: 67749

{
    "key": "ctrl+w",
    "command": "-workbench.action.closeWindow",
    "when": "!editorIsOpen && !multipleEditorGroups"
},

Minus stands for "remove keybinding".

Upvotes: 7

Related Questions