Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Advanced Search Wildcard in Files to Include

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

like image 298
Rich Avatar asked Nov 28 '19 05:11

Rich


People also ask

How do I search inside files in Visual Studio Code?

VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location.

How do I search for a word in all files in Visual Studio?

The new experience is available by searching for “Find in Files” or “Replace in Files” in Visual Studio search (Ctrl+Q by default). You can also get to these commands with Ctrl+Shift+F and Ctrl+Shift+H respectively.

How do I search an entire solution in Visual Studio?

Ctrl + Shift + F – Find in Solution Sometimes you want to search across your entire solution. You can double-click each item in the “Find Results” window to navigate to that instance of the search term you searched for.


1 Answers

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

like image 69
Rich Avatar answered Sep 21 '22 04:09

Rich