Home > Back-end >  Visual Studio Code: in explorer folder, how can I automatically close open subfolders when I close p
Visual Studio Code: in explorer folder, how can I automatically close open subfolders when I close p

Time:11-09

I use Visual Studio Code. I noticed that, compared to PyCharm, it has a lack in the project folder explorer on the left. The case is this:

I open a folder, then I open its subfolders. Then I close the parent folder, but when I reopen the parent folder there are still the subfolders open. I'm not talking about the main project folder, but about the folders inside it (with subfolders)

Is there a way to automatically close and scroll all open subfolders ... if I close the parent folder?

CodePudding user response:

you can do this

alt click

click to the folder you want to collapse

CodePudding user response:

Yes, there is a relatively new command (that is unbound by default): list.collapseAllToFocus

In your keybindings.json:

{
  "key": "alt b",            // whatever keybinding you want
  "command": "list.collapseAllToFocus"
}

Or search for list.collapseAllToFocus in the Keyboard Shortcuts editor and use its UI to give that command a keybinding. Hover over the command and click the sign that appears and enter your keybinding into the input box that pops up.

When you trigger this command on a focused folder, it and all its subfolders will be collapsed. When you open that same parent folder again, its subfolders will still be closed.

  • Related