Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close all tabs, but not the window, in Sublime Text

Is there a way to close all tabs in one go in Sublime Text, but leave the window with the current project open? It is really annoying when I just want to close all open file and start the new task I have to Cmd-W them one by one. If I do Cmd-Opt-W it will close all tabs and the current project.

like image 523
firedev Avatar asked Nov 26 '12 08:11

firedev


People also ask

How do I close a window in Sublime Text?

There is a cmd+shift+w shortcut for closing the project.

How do I open multiple tabs in Sublime Text?

To do so, you need to press Ctrl+K, then Ctrl+Shift+Up. You can repeat as many times as you like. Press Ctrl+K, then Ctrl+Shift+Up to open a new sub-window.

How do I save all tabs in Sublime Text?

{ "keys": ["ctrl+shift+alt+s"], "command": "save_all" }, Now Ctrl+Shift+Alt+S will save all open files. Yay.


4 Answers

Thanks to Alex, it turned out kind of simple, Preferences > Key Bindings > User:

{ "keys": ["super+shift+w"], "command": "close_all" }

No need to restart Sublime, it works right away. And what's even better, no need to get used new shortcuts, you can still close Sublime window with Cmd-W after all tabs are gone.

like image 172
firedev Avatar answered Oct 17 '22 22:10

firedev


There's an option in the file menu, but it has no shortcut:

  • File -> Close All Files

Edit - change user settings:

kay, open Preferences -> Key Bindings - User and paste the following between the []:

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

then use Ctrl, Alt, Shift and w to close all tabs.

You'll have to restart Sublime first.

Note: For Sublime Text 3.2.2,Build 3211 you don't need to restart the sublime text to waste your time.Just place code in [ ](as mentioned above),save it and close Key Bindings - User window.Now all opened tabs will be close with out exiting Sublime Text by using Ctrl + Alt + Shift + W .

like image 33
Alex Avatar answered Oct 17 '22 22:10

Alex


Here is what I have set up on Mac Sublime Text 3

1. Go to Sublime Text -> Preferences -> Key Bindings - User
2. Add the following binding:
[
  ... ... ...
  { "keys": ["command+shift+w"], "command": "close_all" }
]
3. Save file

Now, hitting "Command+Shift+W" will close all of your open tabs. Hitting "Command+W" closes current tab only. This is sort of consistent with Mac shortcuts for other app windows.

like image 25
demisx Avatar answered Oct 17 '22 22:10

demisx


By default, closing all tabs don't close the window, but beware: The last build 3059 (December 13, 2013) of Sublime Text 3 does now include:

Automatically closing windows when the last tab is dragged out

It is managed by this setting:

// Set to true to close windows as soon as the last file is closed, unless
// there's a folder open within the window. This is always enabled on OS X,
// changing it here won't modify the behavior.
"close_windows_when_empty": false,

I just want to close all open file and start the new task

In that same Sublime Text 3 build 3059, you also have the setting:

When the last file is closed, a new transient file is created automatically

Combined with "File -> Close All Files", that can help starting quickly in a new file.

like image 18
VonC Avatar answered Oct 18 '22 00:10

VonC