5

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?

YellowPill
  • 135
  • 1
  • 11
  • 2
    With focus in the Explorer - where your file tree is - just start typing `.scala` and the the files will be filtered. – Mark Nov 03 '20 at 04:54
  • So what you are saying is that I should use Windows Explorer instead of Visual Studio Code? – YellowPill Nov 03 '20 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. – Mark Nov 03 '20 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. – YellowPill Nov 04 '20 at 00:26
  • Would [VSCode 1.70 (July 2022)](https://stackoverflow.com/a/73039128/6309) help in that regard? – VonC Jul 19 '22 at 14:56

2 Answers2

6

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.

YellowPill
  • 135
  • 1
  • 11
5

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 ..

Mark
  • 143,421
  • 24
  • 428
  • 436