Search code examples
searchvisual-studio-codefile-search

In VS code is there option to include files from some folders AND filter by extension/name of file?


Using Visual Studio Code, we have a project with structure of folders. In the folders there are json files which contains various strings and some additional files. Does VS code allow such search, that all applies, so we:

  • Find the text specified in search field
  • Only files from such path/folder will be visible
  • Only files that have some extension/name will be visible

Generally I'm asking if there is some regex/other special char available for search-field files to include.


What I expect (what I'm trying) to enter in Search-box of VS Code:

VS code screenshot of search


Example of folder structure:

base
|-- A
|   |-- AA
|   |   `-- conf.json
|   |-- AB
|   |   `-- conf.json
|   `-. conf.json
|-- B
|   |-- BA
|   |   |-- BAA
|   |   |   `-. conf.json
|   |   `-. conf.json
|   |-- BB
|   |   `-. conf.json
|   |-- BC
|   |   |-- BCA
|   |   |   `-. conf.json
|   |   `-. conf.json
|   `-. conf.json
|-- C
    `-. conf.json


Solution

  • Creating answer, since real answer creator (Mark) just added it in comment. String required to be entered is:

    ./base/A/**/*conf.json
    

    Reason for that is that the ** are used for anything that can be in the tree structure (for multiple folders), where * just fills the space up to the file name between / and start/end.