1

Does anyone know how to fold all "Search Results" grouped by files in Visual Studio code editor? For example, search results are "grouped by files" that are collapsible, but defaulted as open. One can manually collapse the file However, it would be nice if we could collapse all opened files that contain the search results to quickly find the file we are interested in.

In the example below there are 40 files with the word "tax" in them. All 40 files are open showing the details of the search results found. I have manually closed tax-info-summary-panel.component, but would like to have a shortcut to do the same for the other 39 files.

enter image description here

Mark
  • 143,421
  • 24
  • 428
  • 436

2 Answers2

1

There is an unbound command workbench.files.action.collapseExplorerFolders that will do what you want. You will have to make your own keybinding for it (look in the Keyboard Shortcuts for it) or in the Command Palette search for the same comand Search: Collapse All.

Also there is a setting that controls how search results are displayed originally:

// Controls whether the search results will be collapsed or expanded.
// - auto: Files with less than 10 results are expanded. Others are collapsed.
// - alwaysCollapse
// - alwaysExpand
"search.collapseResults": "alwaysExpand"

Mark
  • 143,421
  • 24
  • 428
  • 436
1

After search, you can use collapse all icon for fold all search file and same can be used for unfold. enter image description here

Tyler2P
  • 2,324
  • 26
  • 22
  • 31