Reputation: 20105
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
path/to/folder/
searches in any directories within subpaths matching path/to/folder
including all subdirectories with no restriction in file names../path/to/folder/, ./path/to/another/folder
searches in the directories with the paths path/to/folder
and path/to/another/folder
relative to the project's root directory.Search in files
foo.bar
searches in all files named foo.bar
.*.foo, *.bar
searches in all files with the extensions foo
or bar
../path/to/folder/*/*.foo
searches in all files with the extension foo
that lie in a direct subdirectory of path/to/folder/
relative to the project's root directory.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
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