22

I am trying to find a line of code to all my files with a specific file name criteria. I am trying to take advantage the Advanced Search of the Visual Studio Code by putting a wildcard in the files to include field of the search. But I wasn't able to achieve that. I tried to use asterisk (*) symbol, but I think the Visual Studio Code does not accept that. So I tried to search the internet and found this solution by using the .+?; however, it still does nothing.

Search Keyword: ICustomMatColumn

files to include: (wildcard)viewmodel.ts

enter image description here

Rich
  • 3,505
  • 1
  • 30
  • 60

2 Answers2

18

Apparently, the Visual Studio Code supports glob syntax which is really great. To achieve the desired result in the question you just need to do this format

./**/*< partialFileName >

Example

Folder Structure:

|-- app
    |-- users
        |-- list.ts|html|css|viewmodel
        |-- form.ts|html|css|viewmodel
    |-- cars
        |-- list.ts|html|css|viewmodel
        |-- form.ts|html|css|viewmodel
        |-- configurator.ts|html|css|viewmodel
    |-- app.component.ts|html|css
    |-- app.module.ts
    |-- user.service.ts
    |-- car.service.ts
|-- index.html
|-- main.ts
|-- style.css

Let's Assume that every ViewModel file has this word/code/string ICustomMatColumn

Search Keyword: ICustomMatColumn

Files to Include: ./**/*ViewModel.ts

Search Result:

|-- app
    |-- users
        |-- list.ts|viewmodel
        |-- form.ts|viewmodel
    |-- cars
        |-- list.ts|viewmodel
        |-- form.ts|viewmodel
        |-- configurator.ts|viewmodel

It will strictly include only the files with the partialFileName that you entered in the files to include field

Rich
  • 3,505
  • 1
  • 30
  • 60
7

So I found that the asterisk (*) works when you put in the files to include field the higher level folder name as the criteria

The format will be higherLevelFolderName*

Example:

Folder Structure:

|-- app
    |-- users
        |-- list.ts|html|css|viewmodel
        |-- form.ts|html|css|viewmodel
    |-- cars
        |-- list.ts|html|css|viewmodel
        |-- form.ts|html|css|viewmodel
        |-- configurator.ts|html|css|viewmodel
    |-- app.component.ts|html|css
    |-- app.module.ts
    |-- user.service.ts
    |-- car.service.ts
|-- index.html
|-- main.ts
|-- style.css

Let's Assume that every ViewModel file has this word/code/string ICustomMatColumn

Search Keyword: ICustomMatColumn

Files to Include: app*

Search Result:

|-- app
    |-- users
        |-- list.ts|viewmodel
        |-- form.ts|viewmodel
    |-- cars
        |-- list.ts|viewmodel
        |-- form.ts|viewmodel
        |-- configurator.ts|viewmodel

But the CONS of this solution is in case your search criteria is present in the other file, it will be included to the search result.

Rich
  • 3,505
  • 1
  • 30
  • 60