Is there a menu option or keyboard shortcut to collapse all expanded folders in the sidebar? It gets messy over there and seems like there should be a better way than closing them one by one.
5 Answers
On OSX: option + left click at the root node.
On windows/linux: control + alt + left click

- 14,288
- 5
- 52
- 67
-
78In Sublime Text 3 it's alt + left click – Jordy Mar 30 '16 at 07:34
-
3would really like a keyboard shortcut to close ALL folders – autopoietic Sep 23 '16 at 11:35
-
@Jordy : You saved a mess. – Rahul Apr 04 '17 at 10:15
-
@autopoietic I'm all for not leaving the keyboard (I use VIM mode) but don't you need to use the mouse to interact with the sidebar anyway? – Joshua Pinter Nov 25 '17 at 21:10
-
1@JoshuaPinter ctrl+0 focuses the sidebar, allowing cursor up/down to select/preview files (or cmd+up to get to the top), but I haven't found a shortcut to collapse – autopoietic Nov 28 '17 at 15:26
-
@autopoietic Yep, you're right! Thanks for that tip! – Joshua Pinter Nov 28 '17 at 17:44
-
Is there a way to change this keybind? – Digital Ninja Aug 10 '20 at 09:38
-
Keybindings can be edited in the config file. Open the quick panel and search for 'Preferences: Key Bindings'. – jnns Sep 11 '20 at 08:18
-
@jnns I'm not sure this is a keybind, as mouse actions don't seem to appear in the .sublime-keymap file. – David Cook Sep 23 '21 at 01:54
-
1There doesn't seem to be a relevant [command](https://sublime-text-unofficial-documentation.readthedocs.io/en/sublime-text-2/reference/commands.html) so guess it's not possible to customise this. – David Cook Sep 23 '21 at 01:54
-
1@DavidCook It seems you're right. The `.sublime-mousemap` file doesn't have anything on this either and running `sublime.log_commands(True)` in the console doesn't show a command being run when sidebar folders are collapsed/expanded, either. – jnns Sep 23 '21 at 07:57
For Sublime Text 3 on Linux Mint 17.2 w/ Cinnamon I had to disable the following setting:
System Settings->Windows->Behavior->Moving and Resizing Windows->Special key to move and resize windows
After that Alt+left click worked!

- 2,406
- 6
- 28
- 34
-
1And for those using compiz: CompizConfig Settings Manager -> Window Management -> Move Window -> click the Alt
button and disable it. Edit: disable actually seems to not be saved, try adding an unused complex combination as a fake disable. – morunas Sep 28 '16 at 17:12 -
1Also for Mint 17.3 w/ MATE (the setting is found in [start] -> Preferences -> Window) – StefanNch Jun 15 '18 at 06:18
-
2Worked in xfce4 too. Settings -> Window Manager Tweaks -> Accessibility(tab) -> **key used to grab and move windows property** set to **None**. – Ravindu Sachintha May 05 '20 at 00:18
Keyboard only
To collapse all expanded folders in the sidebar on macOS:
ctrl + 0
: Focus the sidebarhome
orcmd + up
: Select first root folderctrl + left
: Collapse all sub-folders (confusingly, notalt
as per the equivalent mouse action).- (optional)
right
: Expand just the top level folder.
Thanks to the existing responses that provided this info.
I've not tested on other platforms, please update the answer if you can.

- 483
- 7
- 25
In Sublime Text 4, pressing "option/alt" on your keyboard and clicking a folder in Sublime's sidebar with your mouse, will collapse all sub-folders within the folder you clicked. I'm using a Mac. I'm not sure what happens on other operating systems.

- 101
- 4
using purely keyboard, on a mac, to unfold
CMD + K + 0
to fold, depending on the level of indentation
CMD + K + {level of indentation number} (eg. CMD + K + 2)
Refer here for more details functions of sublime text. Found this really helpful

- 1,512
- 17
- 25
-
-
2This answers the question how to expand and collapse code in the main editor window, not how to collapse and expand folders in the sidebar. – Alexander Popov Mar 22 '18 at 08:55