sferrari
sferrari

Reputation: 343

Any way to view VSCode "find in files" results organized by folder hierarchy?

I'm coming from Eclipse where searching for a string across files using ^h organizes the results by the folder in which they were found, like this:

search results

This is very handy, as folders can be collapsed and expanded to narrow the results. Is there a similar capability (out of the box or via an extension) for vscode?

Upvotes: 19

Views: 3243

Answers (3)

VonC
VonC

Reputation: 1327754

VSCode 1.72 (Sept. 2022) should help, since issue 20224 is now fixed by PR 161022.
There is a new action "View as Tree" (search.action.viewAsTree).
This is available in VSCode Insiders today.

Anil reports in the comments:

The settings value is search.defaultViewMode. See "Default settings".

  // Controls the default search result view mode.
  //  - tree: Shows search results as a tree.
  //  - list: Shows search results as a list.
  "search.defaultViewMode": "list",

Search Tree

Shows the search results in a toggle-able tree.

https://user-images.githubusercontent.com/31675041/190530991-7f4b0501-4fc4-4ac6-b383-c248f876c049.png

And

https://user-images.githubusercontent.com/31675041/190531035-cb35e877-cf9c-4832-8acc-71988445d12b.png


With PR 173080, VSCode 1.76 (Feb. 2023) introduces an extra state for search tree view collapse, as described in issue 162812.

The default functionality should be the collapse the individual matches and only see the files/folders.
Similar to how multi-root works

https://camo.githubusercontent.com/9e563a6d56f8dd0eafb2f9da11a3b3756f97f80719155ca7504d9717a4d391ea/68747470733a2f2f692e6779617a6f2e636f6d2f66623136333363373063333337366562303866633935306530353039393332662e676966

Upvotes: 5

Milad
Milad

Reputation: 732

Now available in the new version of VSCode and can be done by using the new icon on the top of the search panel.

Upvotes: 3

leo-diehl
leo-diehl

Reputation: 11

Unfortunately no.

It's been 5 years since this feature has been suggested, but with no implementation yet despite the constant bumping of the issue and a lot of upvotes.

https://github.com/microsoft/vscode/issues/20224

Upvotes: 0

Related Questions