-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove CtrlCmd+W keybinding to close window when no editors are opened #54492
Comments
@graham-sportsmgmt just add this to your keybindings file and it should be OK: {
"key": "ctrl+w",
"command": "workbench.action.closeActiveEditor"
} |
That's what the default keybindings.json already has:
Could you please read my post again and let me know which parts need clarification? I'd like to make sure you understand the issue but your comment makes me believe you don't. |
@graham-sportsmgmt can you please just do what I said in #54492 (comment) and then see if that fixes your issue and if not we can continue the discussion? |
Yes, after adding that line ctrl+w does not close the Workspace. This bug requests that as the default behavior without needing to edit keybindings.json. |
@graham-sportsmgmt but closing the Window when pressing |
It's common for web browsers, but web browsers aren't IDE's. |
I agree. I hit this bug too often. Ctrl-W is common for closing a tab or a document in MWI applications, but it is very uncommon for closing the application itself, except browsers which are closed when the last tab is closed. In VS Code there is a preference for that: For example, MS Office apps close the active document on Ctrl-W, but they don't quit. I vote for changing the default behavior. |
+1 for default behavior. Current behavior is just annoying. no one uses vscode as browser, BTW ^_^ |
The utter insanity och having |
I tried setting the keybinding as suggested here without success, editing the keyboard shortcut preferences worked for me though (I just set a shortcut that I won't use) Maybe there could be a more prominent setting to toggle this behaviour? I'm not sure about what should be the default, but making the setting more accessible would help. |
Hello, this is super annoying I often close my vs code with all running tasks by accidentally press Ctrl+W. A heritage of electron :) |
Hi "graham-sportsmgmt", the answer is simple. You don't have to CHANGE the command. You just need to DELETE it in the following way:
The above-given way will solve your problem. I'm like you about that. I use the "ctrl+w" shortcut very, very often. But before, when no files were open, the "ctrl+w" shortcut would close Visual Studio Code completely! I hated that! So I deleted the whole "Close Window" line. And now the "ctrl+w" shortcut only closes files, not the whole Visual Studio Code, which will stay open as long as you want. |
IMO @houh60 has the answer. I appreciate that @graham-sportsmgmt asked for the default behaviour to be amended, but VSCode is a highly configurable editor. The simple tweak to the keybindings, as stated by @houh60 resolves this issue. And if you're using an extension like Settings Sync to persist your settings across your different machines, you'll never have to worry about it again. |
+1 that this should be default behavior! |
I also expected this would be the default behaviour when I switched to VSCode. Thanks @houh60 for sharing his solution. I also deleted the corresponding line, so everything's fine for me now. (In addition to that, I also deleted the "close window" command for "Ctrl+Shift+W" and then edited the command for closing all editors (originally Ctrol+K+W) to "Ctrl+Shift+W". It's actually the same reason - I'm used to Ctrl+Shift+W from other applications.) I found this thread on Github after I didn't find any setting inside VSCode and then explicitly searched for a solution here. So before searching here, I opened the VSCode settings (Ctrl+,) and found the "Window" section. Over there, I can decide whether closing the last editor should also close the whole window. I'm sure I'm not the only one who checked those settings in order to change the Ctrl+W behaviour. Therefore, I would like to propose to extend this setting, so everyone can define their desired behaviour over there as an alternative to changing the default behaviour. |
remove |
Echoing what has been said or voted on by many above: please make not closing the application the default behavior with control+W. It's likely some developers may just live with the behavior and not seek out a solution. (It's been a few months until I decide to search around and see if I could fix this behavior.) There's likely thousands of developers who've come across this thread over the past three years, found the workaround, and left after applying it. But from those who have stuck around to share their thoughts, it looks like there is a strong trend from the community which sees the existing default behavior as more of a hindrance than a help. For those advocating not changing the default but instead to follow the instructions in remove the closing behavior - the same ease of configuration, that has been expressed, would be true for those who want to configure it back to the current behavior. An easy win would be to change the default to what the community outlined above. The minority, who want the legacy closing behavior, would just need to reconfigure it to close the APP when no windows are open and CTRL+W is pressed. |
Echoing @tronster's echo of all things to be echoed. I also finally got around to googling this after accidentally closing everything too many times. I feel it should be the default behavior. |
According to the release notes, this looks solved. https://code.visualstudio.com/updates/v1_51#_prevent-accidental-close |
@orgads, that would be great. Taking a look using 1.51 (and then 1.51.1) and it doesn't appear to be in there. Or at least it's not enabled by default and is not a setting in "File > Preferences > Settings". |
This is still a bug in 2021. This issue is so simple, why hasn't it been fixed yet? |
I was also having the same issue. adding this in keybindings.json file helps: { This will close active editor by cmd+w . But will not close the vscode window when no editor is open. |
@kartikeytewari solution works like a charm, if you are on windows just change |
But this was exactly the frustration not only a lot of users had but even in the team: when you rapidly close tabs you might accidentally close the entire window because you continued to issue the "Close Editor" command when no editor was opened and that would close the window. |
Windows is certainly inconsistent. Ctrl+W varies from app to app (things like Explorer, Notepad, and web browsers all allow you to close the window when there's nothing left to do). If people are adamant that the Windows behavior take a "do not close" stance, I can at least understand that because it's case-by-case. But it's unquestionably incorrect behavior on Mac to allow Cmd+W to close tabs but prevent it from closing a window. |
I think so, yes. As I understand it and as I read it, it means that Cmd-W closes one active window, Cmd-Shift-W closes multiple windows (all associated with one document), Opt-Cmd-Shift-W closes all open windows of the app. The latter two seem to be somewhat outdated recommendations back from when apps used to have multi-document interfaces. I tested this with the single-document interfaces of the Xcode IDE from Apple and the editors Coda and Nova from Panic; all three close documents with Cmd-W, leave the app window open after the last document is closed, then close the app window for another Cmd-W (but not quit the app, which is Cmd-Q). Also, this is different from Windows and Linux: on MacOS, closing the app window does not quit the app. So the app is still running and active and restoring the window is one more keystroke away (e.g. Cmd-N for new file). As opposed to Windows and Linux where closing the window does quit the app, meaning you'll have to start it up again from the Start Menu or from wherever, possibly involving mouse action. |
Great, I was about to test that. It makes sense to behave like Xcode here imho. I think we should push a change then for macOS specifically to revert it there. Will investigate as part of our recovery release. |
Recovery issue: #126042 |
I preferred being able to use ctrl + w to close the application. This is really annoying now. Alt + F4 doesn't really work for me since I have a keyboard which requires you to hold the FN button to be able to use the F keys. |
@CalumFormby you can override the new behavior.
|
This was not a valid bug, but a default/standard behaviour. (E.g. in other editors like Notepad.) You need to learn to be more careful what keyboard shortcuts you hit, if this is a problem for you. |
Lots of people here are not liking this change, that's understandable, not everyone will be happy. I read this in the changelog, and audibly said "yes! thank you!". Thank you, vscode team! Closing a workspace is sufficiently different action than closing a window that it should be a different keystroke. Re-opening a workspace is sufficiently more annoying than re-opening a file that this footgun should be avoided by default. I often found myself closing several terminals that I did not want to close, simply for pressing this button one too many times when closing open files. |
@shamelesscookie Awesome, thanks for that :) |
@ryanhiebert I can understand having Ctrl-W removed for closing the workspace in Win/Linux because closing the window also quits the app and you have to re-start it, possibly using the mouse. But Cmd-W on Mac works the same in every app: it closes the window but does not quit the app which even remains active. So re-opening it is just another keystroke away (e.g. Cmd-O to open or Cmd-N for new file which in this case only re-opens the window). In any case, it looks like they will leave out Ctrl-W but reinstate Cmd-W in the next update, so that will probably, hopefully, maximise the number of happy people. Another thing is that you can always, instead of Ctrl/Cmd-W-W-W-W-W-W-W-W-W-W-W-W-W-W, use the long established keyboard shortcut Ctrl/Cmd-K,Ctrl/Cmd-W to close all editors in one go. See Ctrl/Cmd-Shift-P and type "close". |
I am on a Mac. I love my Mac. I really like that closing windows does not close the application. But closing tabs in bulk should not end in closing my workspace, which is far more than just a collection of tabs. As I mentioned, I regularly run terminals. Sometimes these are environments that are a bit annoying to set up. It sounds to me like you think command+w should close the workspace. I disagree, but I can make sense of that, from the standpoint of consistency with other applications. I can't make sense of thinking that closing an editor and closing a workspace should share the same keystroke. Thanks for the cmd k+w hint, I'm glad it exists. Sharing this shortcut between wildly different app-specific contexts is still an obvious footgun that would be wise to avoid, imo. Having a command that doesn't explode your workspace because you pressed the keystroke that closes a single editor still seems like an importantly better user experience to me. Requiring users to avoid common usage patterns because those patterns will make their workspace evaporate unintentionally seems like a less than optimal default experience. |
Sounds to me like you never really use Cmd-W to close a window, only ever to close tabs. If that's the case, I think I may never convince you! Which is fine. I do think the right decision is to conform to Apple Human Interface guidelines and act the same as any other app on MacOS, also Xcode for instance, and have Cmd-W by default always close the currently active "window" whether that's an editor tab or the workspace window. If you want non-standard behaviour like in this release (i.e. Cmd-W never closes the Vscode window) then you can define that in the settings by adapting #54492 (comment) (I guess it would mean deleting that from the settings? I'm not sure) |
Now in vscode 1.57.0, Cmd-W can't close an empty window. |
@ednl: Actually, I do close the window frequently via cmd-w. Sometimes intentionally, sometimes not. I also think that cmd-shift-w being the exclusive way to close the project window entirely is preferable. I find no particular precedent for how to decide this interface. The HIG guidelines, as far as I can tell, don't say how to handle tabs at all, though it seems likely that I've missed it, since I'd have guessed they would have extended them as they applied them to their own applications that have tabs. Safari, finder, and others that I can think of are importantly dissimilar to vscode in that closing the final tab in those applications also closes the window. There is no sufficient purpose for keeping the window open once all the tabs have closed in those applications, but that is most certainly not the case in this application. I think you'll agree with that, since I do not think you're advocating that the window itself should be closed along with the final tab. A precedent worth considering is that the command to close the window is cmd+shift+w (except when the tab and the window are one and the same). You can think of it like "close all tabs", but that is constrained to one window, and importantly, the menu clearly assigns the shortcut to "close window". That's my reasoning. One final word of caution from me. When you say "the right decision is to conform to Apple Human Interface guidelines", I totally agree. But I haven't found any word about this distinct case, so I must draw on other precedent to find what seems like the most natural application of the principals it has laid out. We disagree on what is most natural, and that's perfectly okay. I believe the way you're applying the HIG to this case is reasonable, but suboptimal. However, the way your statement about the HIG comes across to me as suggesting that yours is the only possible way to apply the HIG to this situation. While I don't hope to have convinced you that my preference is optimal, I do hope that you understand that unless and until this case is clarified in the HIG, there are indeed other reasonable applications of the HIG than your preference, and that the behavior as implemented is one of them. |
How am I supposed to close all tabs in a workspace and the window if I have three files open? Before this change: After this change: Is there a more efficient way? |
@gavinr On Mac, Shift-CMD-W will now close the window and all its' tabs. Try Shift-Ctrl-W on Windows |
@ryanhiebert Yes, it is my interpretation of the HIG, but I think it is the right one ;) You are right: the HIG hasn't been updated with explicit reference to tabs as used by single-document interface apps (as opposed to what was the norm: multiple separate windows in a multi-document interface). See my earlier comment at #54492 (comment) I agree on browsers being different. But Xcode and other editors like Panic's Coda and Nova behave like what I think is the norm: close tabs one by one, then close the app window. |
Xcode at least is significant precedent. After my last comment, I did open Xcode and saw that it worked that way. I think my preference would be better, but 🤷. I'm not familiar with the other editors personally. Good talking with you! |
Before this change: After this change:
|
This change is a shame, you've changed the common behaviour we've been using on mac for 30 years |
I’m not sure why this is even a discussion, the standard Mac behavior is simple:
VSCode is a pretty good Mac app, but this decision suggests you should hire a Mac UX person for consultation. |
@julian3xl @mxcl Apparently this is going to be reversed for Mac in the next update, see #54492 (comment) |
Not a Mac person, but still preferring prior behavior. Thank you for the workaround @shamelesscookie . |
I'm a Linux user and I'm also confused about the new behavior. especially with multiple opened windows it was good to close just the current window with ctrl + w if no tab was opened and close all windows with ctrl + q also from me: thanks to @shamelesscookie for the solution |
@mxcl @ednl. I think that this suggestion, if implemented well, would alleviate my challenges with the previously existing behavior that prompted this change in the first place. I'm not sure how well vscode can detect whether terminals and other things (perhaps extensions?) that might be important to the user and annoying to recreate are open, but if that could be done reliably, I would drop my objection to I still think that |
I really think that's the best UI possible, and that's the reason why I made QuitControl extension. Pressing |
I feel like this should maybe be an easy setting instead of a keybind that users have to configure themselves (similar to the existing "close when empty" setting)? In my opinion, CTRL+W to close the window when no tabs are left is the logical thing to do, but I can certainly see why it could be annoying if done unintentionally (never had it happen, but fair enough). I can also see why people who are annoyed by this would look through the settings first before adding a custom keybind. But changing the default behavior was a bit unnecessary. And lastly, I really don't think this should've been a bug report. Reopening the linked feature request issue asking for an easy setting is one thing, but this is not a bug. It's a deliberate choice, that (in my opinion) better fits the text editor-like style of VS Code.
And thanks to @shamelesscookie for the workaround! I (ironically enough) actually thought this change was a bug on my end lmao |
FWIW: To me it seems like prior behavior was also more in line with Ubuntu at least (don't want to generalize for the whole Linux world). gedit, gnome file manager, gnome terminal and of course the browsers close the window with or after closing the last tab. I like the behavior for applications which I usually have open in multiple windows with multiple tabs each. As a former Windows user I understand that these key bindings may not be familiar. Therefore, not sure what the default behavior should be and also not sure whether different behavior on different OS is great (I for one work on multiple platforms). ¯\_(ツ)_/¯ |
This could be viewed a duplicate of this Feature Request, but I'm reopening it as a bug for two reasons:
I frequently use
Ctrl + W
to close the active editor. When there are no open Windows (i.e. editor tabs) pressingCtrl + W
closes the Workspace (i.e. the entire VS Code application) which is not the behavior I want.In the Keyboard Shortcuts menu there are default bindings for
Ctrl + W
to "Close Window" andCtrl + K + F
to "Close Workspace".In Version 1.25.1 when there are no open editors, pressing
Ctrl + W
(wrongly) assumes that I wanted to issue aCtrl + K + F
/ Close Workspace command. In this situation the desired behavior is no action as:This could be fixed by either disabling Close Workspace on
Ctrl + W
or adding a configuration option that lets me control the behavior ofCtrl + W
when no editors are open.The text was updated successfully, but these errors were encountered: