15

How can I search in one subfolder folder of my workspace only?

CTRL+SHIFT+F searches in the whole workspace, and since this is large I get way too many hits in unrelated folders and files.

Jeroen
  • 56,917
  • 35
  • 193
  • 305
El Dude
  • 5,020
  • 9
  • 44
  • 86

3 Answers3

16

Two options:

  • Left-click the folder in the Explorer and use ALT+SHIFT+F
  • Right-click the folder in the Explorer and choose "Find in folder..."

This will give you a slightly changed search bar:

vscode search in folders sidebar

Jeroen
  • 56,917
  • 35
  • 193
  • 305
3

The key combo is ALT+SHIFT+F

p.campbell
  • 95,348
  • 63
  • 249
  • 319
0

Another twist on this is how to search in a collection of named subfolders. For example, consider a directory structure like this:

Project
├── Foo
│   ├── inc
│   │   ├── tom.h
│   │   └── dick.h
│   └── src
│       ├── tom.cpp
|       └── dick.c
├── Bar
│   ├── inc
│   │   └── harry.h
│   └── src
│       └── harry.c

The "files to include" box will accept glob notation, so if the user wants to search only in "src" directories, not in "inc" directories, they can specify:

./**/src/*

This is interpreted (from right to left) as "any file, in a 'src' sub-directory, underneath any directory".

Obviously, this is a trivial example which could be handled by filtering on the file extension, but the principle applies to much more complex searches. For another example, see: https://stackoverflow.com/a/59083215/6419400

Dave C
  • 111
  • 1
  • 3