147

In Visual Studio code, how do I search for just a specific file type (i.e. *.css or *.ts)?

PS: I'm talking about the global search (Ctrl+Shift+F in Windows)

I'm already using the "files to include" as a folder filter. So currently it has something like ./src/app.

1
  • 2
    @OcelotXL Ctrl + Shift + F in Visual Studio Code in Windows (as opposed to Visual Studio Code in Mac or Visual Studio Code in Linux). Just to be clear!
    – Theraot
    Jun 19, 2019 at 17:28

3 Answers 3

213

Click the ellipses on the bottom right to display the "files to include" field.

You can specify a particular type with "*.filetype".

E.g.

screenshot

13
  • 3
    Ok, sorry, I forgot to mention that I'm already using the "files to include" as a folder filter. So currently it has something like "./src/app" Oct 5, 2017 at 15:57
  • 10
    Update: just realised I can simply do "./src/app/*.ts" :D Thanks! :) Oct 5, 2017 at 15:58
  • 18
    To group filters, you can use {}.. Like: {./src/app, *.ts}
    – DeBorges
    Jan 25, 2019 at 9:15
  • 13
    how do I search for all files of that file type? when I leave the search blank it doesn't search... Jun 18, 2020 at 15:39
  • 11
    @ChagaiFriedlander Asking the real questions! This is my issue, also. I want to step through every *.js file in my folder. I don't want to and cannot search for a certain content. Aug 10, 2020 at 17:28
121

You can do this.

./src/app/**/*.ts

other glob syntax

  • * to match one or more characters in a path segment
  • ? to match on one character in a path segment
  • ** to match any number of path segments, including none
  • {} to group conditions (for example {**/*.html,**/*.txt} matches all HTML and text files)
  • [] to declare a range of characters to match (example.[0-9] to match on example.0, example.1, …)
7
  • Exactly what I was looking for. Could you provide the source link, please? Thank you.
    – sdlins
    Jan 6, 2020 at 19:54
  • 1
    Thanks @sdlins, you can find it on vscode doc somewhere here code.visualstudio.com/docs Jan 9, 2020 at 5:31
  • 13
    FWIW the braces aren't necessary to group a file type only query, and make sure to include a comma to separate file types, e.g. *.css, *.ts, *.js, *.html
    – Slate
    Jan 29, 2020 at 9:37
  • 4
    @sdlins Here's the exact source link in the VS Code docs: code.visualstudio.com/docs/editor/… Sep 9, 2021 at 15:37
  • 3
    This should be the approved answer. It actually provides a way to search both "within a specific folder" and "by filetype".
    – Riveascore
    Sep 14, 2022 at 23:17
-1

You can use the file search option (ctrl+p), then copy the subfolder relative path in the project, followed by the pattern to search the files. For example:

subfolder_path/*.hpp

In the provided list, you can open each one by using the right click ... unfortunatelly I did not find a way to store the list somehow.

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 2 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.