171

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! Commented Jun 19, 2019 at 17:28

4 Answers 4

237

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

Sign up to request clarification or add additional context in comments.

14 Comments

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"
Update: just realised I can simply do "./src/app/*.ts" :D Thanks! :)
To group filters, you can use {}.. Like: {./src/app, *.ts}
how do I search for all files of that file type? when I leave the search blank it doesn't search...
@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.
|
151

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, …)

5 Comments

Thanks @sdlins, you can find it on vscode doc somewhere here code.visualstudio.com/docs
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
@sdlins Here's the exact source link in the VS Code docs: code.visualstudio.com/docs/editor/…
This should be the approved answer. It actually provides a way to search both "within a specific folder" and "by filetype".
How to trigger the search then? It does not seem to work, unless I additionally use some phrase to search in the files.
0

Press Ctrl + shift + F, which opens a window where you can search for a specific file type.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
-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 Comment

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.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.