In the Search pane of the program, after I hit Enter, all files are listed, with some expanded to show results in a file, and others collapsed. I'm wondering firstly what determines the expansion of any given file, and secondly what I can do to expand all of them at once.
This question seems closest to mine, but it's about a different IDE, and the key commands it suggests for Windows had no apparent effect: Automatically expand all in Eclipse Search results
Fold All (Ctrl+K Ctrl+0) folds all regions in the editor. Unfold All (Ctrl+K Ctrl+J) unfolds all regions in the editor. Fold Level X (Ctrl+K Ctrl+2 for level 2) folds all regions of level X, except the region at the current cursor position.
CTRL + M + P will expand all and disable outlining. CTRL + M + M will collapse/expand the current section.
VS Code allows you to quickly search over all files in the currently-opened folder. Press Ctrl+Shift+F and enter in your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location.
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://stackoverflow.com/a/67307225/836330 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
toauto
to revert to the old behaviour.
And see Visual Studio Code - Include context in search results for showing the search results in an editor.
There are two quick ways to expand all at any time:
Both of these only work for the Search panel though – despite the similarity, they do not work for the "Find All References" results panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With