visual-studio-code

VS Code: icon/button for Collapse Folders in Explorer


On the top of the explorer sidebar I accidentally removed a button and I can't figure out how to get it back.

On the top right of the explorer sidebar, there is the '3 dot button'. Next to that, there was the icon of a folder. When clicked, it would have the same result as when clicking on the three dots and then choosing 'Collapse Folders in Explorer'.

I looked into keybindings for the same behavior, but CMD + left arrow also collapses the root folder that the project is in, which is what I don't want.

The 'Collapse Folders in Explorer' doesn't do that, it only collapses any open subfolders (any levels deep) in the first layer of folders in the root project folder. And that's what the button that I accidentally removed also did, which why I want it back :-)


Solution

  • ctrl/cmd+left is list.collapseAll. The command ID you want is workbench.files.action.collapseExplorerFolders, which collapses all folders, and when the workspace is a multi-root workspace, will only collapse folders under workspace root folders if there are any that can be collapsed, and otherwise will collapse all the root folders.

    You probably toggled away your collapse button. The way to toggle it away and back again is to right click any of the (remaining) action buttons (but not the three dot menu button), which will drop down a menu where you can click an option that says "Hide 'Collapse Folders in Explorer'" if the button is there and you right click it directly instead of another action button, and "Collapse Folders in Explorer" with or without a checkmark if you right click on another action button (checked means it is currently shown, and uncheck means it isn't, but clicking it will make it shown again).

    If you've hidden all the action buttons and have nothing left to right click, use the View: Reset All Menus command in the command palette.


    Next to that, there was the icon of a folder. When clicked, it would

    My icon for it is not a folder. It's /. Maybe you're using a product icon theme or something...