Created
November 4, 2020 16:26
-
-
Save MattDMo/3bb35ec5f91ef2d06ada62f78fe00ef4 to your computer and use it in GitHub Desktop.
Sublime Text - Close all open windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sublime | |
| import sublime_plugin | |
| class CloseAllWindowsCommand(sublime_plugin.ApplicationCommand): | |
| def run(self): | |
| for win in sublime.windows(): | |
| win.run_command("close_window") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { "keys": ["ctrl+alt+shift+w"], "command": "close_all_windows" }, | |
| ] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is in response to this StackOverflow question which asks how to close all open windows at once.
First, select
Tools → Developer → New Plugin…and change its contents to that ofclose_all_windows.pyabove. Hit Save and it will automagically save it to yourPackages/Userfolder, wherePackagesis the folder opened when selectingPreferences → Browse Packages…:~/.config/sublime-text-3/Packages~/Library/Application Support/Sublime Text 3/PackagesC:\Users\YourUserName\AppData\Roaming\Sublime Text 3\PackagesInstallationFolder\Sublime Text 3\Data\PackagesNext, select
Preferences → Key Bindingsand add the keybinding inDefault.sublime-keymapto the User keybindings on the right. I chose CtrlAltShiftW, feel free to customize it if you want. Make sure you save the file when you're done.Now, when you're in a situation where you have a ton of open windows you want to get rid of, just hit the keybind and they'll all close, unless there are unsaved files open, in which case it'll ask if you want to save or cancel.