Sublime Forum

Please remove default key binding CTRL+W


I know I can remove this binding by myself. But I needed a while to understand why sometimes my file was closed just after saving it!

Using CTRL+S on a German keyboard, it’s very likely that I also hit the neighbor key W when pressing CTR+S. So the result is that I save and close the file.

So please remove that default CTRL+W key binding.




Closing files/views via ctrl+w is a default Windows convention effecting many applications, but not only ST. I personally prefer using that instead of ctrl+f4 because it is easier to hit (on my german keyboard).



Maybe you could remove the W on your keyboard instead.



Indeed, never realized that. Probably because I don’t save so much and so often as in SublimeText.
Some observations: In Outlook CTRL-W has no effect. In Word, PowerPoint and Excel it closes the current document. In Firefox it closes the current tab.

However, I still think that it would be better to not have such a default in ST:



With hot_exit: true you basically don’t need to save files too often at all - at least not because of fearing data loss. All modifications of even unsaved files are persisted in the session and are restored if you open ST the next time - even after crash situations. I never lost any unsaved changes so far. ST is no Micros… Word which crashes every 5mins. :wink:

That said, you can always disable or override key bindings to tweak the bahavior of ST to your own personal preferences. Removing it by default doesn’t help other people loving that binding.

For the record: Just add the following line to your Packages/User/Default.sublime-keymap file to disable the key binding.

{ "keys": ["ctrl+w"], "command": "" },


When I turned on hot exit I remapped cmd+q because accidently quitting is really annoying and I because I have a need to quit ST about twice a year.



I think hot_exit is true by default. I also have no problems with crashes. The actual reason, why I don’t like accidental closing of the file is that the undo stack is deleted. Is there also an option to save and restore the undo stack after closing the program?

I already deactivated the CTRL-W option, thanks for the tip.



Also, after closing the program or file, the code is fully unfolded. This is also something that could be remembered by ST.



A persistent undo stack was discussed resently with the conclusion of something like that being part of the functionality a version control system would be a better choice for. It is always possible to create commits with small changes or milestones to go back to at any time. Once everything is done the commits of a branch may be squashed then.

With regards to folding, you are right. Would be nice to keep folding states intact.
You may want to give AutoFoldCode plugin a try for that.



I’ll try autoFoldCode.

BTW: Another code folding related thing is that when I copy folded code, it’s pasted unfolded. It would be cool if the folded state is preserved after pasting code.

Same idea when duplicating folded code using CTRL-SHIFT-D.



You might want to file an enhancement request at with a detailed description of what you expect.

Once the core devs decide to work on text folding, they could pick up your issue to get an idea about what users expect from it.