Sublime Forum

Please remove default key binding CTRL+W

#1

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.

Regards
Alexandru

0 Likes

#2

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).

4 Likes

#3

Maybe you could remove the W on your keyboard instead.

5 Likes

#4

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:

0 Likes

#5

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": "" },
3 Likes

#6

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.

0 Likes

#7

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.

0 Likes

#8

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

0 Likes

#9

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.

0 Likes

#10

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.

0 Likes

#11

You might want to file an enhancement request at https://github.com/sublimehq/sublime_text/issues 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.

0 Likes

#12

Okay: https://github.com/sublimehq/sublime_text/issues/3162

0 Likes