7

I want to see a filtered list of all the files in my project that have a specific extension.

As Im using a Scala language the files have the extension ".scala", so i would like to see a filtered list of all the files with a ".scala" extension.

The following post shows some techniques but nothing showing how to achieve what I require. How do I search for files in Visual Studio Code?

5
  • 2
    With focus in the Explorer - where your file tree is - just start typing .scala and the the files will be filtered. Commented Nov 3, 2020 at 4:54
  • So what you are saying is that I should use Windows Explorer instead of Visual Studio Code? Commented Nov 3, 2020 at 19:18
  • No, the Explorere is the part of vscode that shows your files. It says "Explorer" at the top when you have it activated by clicking the top icon in the Activity Bar - where the Search/Debug/Extensions icons usually are. Commented Nov 3, 2020 at 20:15
  • right got you. I tried it and it worked! I did some further looking at the Visual Studio Code website and found the answer as you described it. Commented Nov 4, 2020 at 0:26
  • Would VSCode 1.70 (July 2022) help in that regard? Commented Jul 19, 2022 at 14:56

2 Answers 2

7

Based on @Mark response I enhanced my knowledge a bit further.

Here is the link to the Visual Studio Code website that explains it in more detail

https://code.visualstudio.com/docs/getstarted/userinterface#_filtering-the-document-tree


Summary

  1. Click on the "Explorer" icon in Visual Studio Code.
  2. Click on the "Explorer" panel background and type what you want to filter.

In my case i typed ".scala" and all other that did not have the scala extension were removed from view.

To remove the filter, simply click the cross next to the red text that represents what you typed as a filter.

The cross appears when you hover your mouse over the text.

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

1 Comment

This only seems to work with files you've recently opened for some reason
6

As VonC mentioned in the comment, see also his answer at How to filter files shown in Visual Studio Code? in vscode v1.70 you should be able to filter the Explorer to show only files with a particular extension by typing .json for example into the new Find Widget for lists (the Explorer files is a list).

Demo:

filter the Explorer by extension

Note that there is a json.txt file that is not shown if you begin the filter with the ..

3 Comments

Typing .js works, +1. Typing abc*.js does not work for now.
@Mark What program did you use to make the animated example?
@Rich I used screentogif.com for that. But vscode has instituted some draconian limits on gif attachments now so that only the very smallest gifs can be used. The one above would not be accepted anymore. If you want it for other reasons though, I still like it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.