Sebastian Zartner
Sebastian Zartner

Reputation: 20105

How to search for files in different directories recursively in VSCode?

Visual Studio Code (as of version 1.41.1) is obviously very limited in regard of its file search. It seems to only allow to either search in folders recursively or in specific files, but it doesn't allow both.

Search in folders recursively

Search in files

Search in folders recursively and filter by file name

So, how to combine these two searches, i.e. filter the search by file names but search in specific directories with all their subdirectories?

In other editors like Eclipse you normally have two different fields for file names and folders, making it easy to specify them individually and avoid having to repeat yourself for multiple folders and file names. Therefore I have already created an enhancement request in the VSCode bug tracker asking to add a separate field for the folder.

Upvotes: 3

Views: 5376

Answers (1)

Mark
Mark

Reputation: 181429

In my testing, using the globstar does provide the functionality you desire.

https://github.com/isaacs/node-glob#glob-primer:

** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.

So that ./path/to/folder/**/*.foo for example searches within all subdirectories of folder no matter how deep within files with the foo extension.

Same at https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options:

** to match any number of path segments, including none

Upvotes: 4

Related Questions