With vscode v1.89 (it is in the Insiders Build now), there is a context menu option when you right-click on a folder in the Search Results:
Expand Recursively
This would be helpful if you had the Search: Collapse Results
setting set to default
or alwaysCollapse
(mentioned below). Then you could right-click a particular folder you want to open (and its child folders) without having ALL the search results folders open by default.
There is also a command search.action.expandRecursively
you can bind to a keybinding to do the same:
{
"key": "alt+x", // choose your keybinding
"command": "search.action.expandRecursively"
}
If a folder is focused in the Search Results, then triggering this command will recursively open only it and its subfolders.
See this setting:
Search: Collapse Results
in the Settings UI or
search.collapseResults: alwaysExpand
in your settings.json
file
The options are auto
,alwaysCollapse
, and alwaysExpand
. auto
is the default.
auto
: Files with less than 10 results are expanded. Others are collapsed.
So you want the alwaysExpand
option.
You can also toggle any file expanded/collapsed with the Space key or just expand any collapsed file with RightArrow.
Collapse with LeftArrow and collapse all with Ctrl+LeftArrow. Oddly, there is no expandAll
binding or command.
And see https://mcmap.net/q/505360/-fold-all-quot-search-results-quot-in-visual-code-editor for a command to collapse all the results that you can set to a keybinding:
workbench.files.action.collapseExplorerFolders
as in
{
"key": "alt+l", // whatever you want
"command": "search.action.collapseSearchResults",
"when": "searchViewletFocus" // if you want to limit it when focus is already on the search results area
}
in your keybindings.json
.
v1.41 is making expanded search results the default, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_41.md#search
Expand all search results by default
Previously, if a full text search returned more than 10 results in a
single file, it would appear collaped in the results tree. However,
this sometimes made finding a particular result difficult, so with
this release all results will appear expanded. You can set
search.collapseResults
to auto
to revert to the old behaviour.
And see Visual Studio Code - Include context in search results for showing the search results in an editor.