Filter files shown in Visual Studio Code

Visual Studio-Code

Visual Studio-Code Problem Overview


How would you filter files shown in folder view in Visual Studio Code?

Reference: Filter files shown in folder view

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

Hiding files and folders

The files.exclude setting lets you define patterns to hide files and folders from several places in VS Code like the explorer and search. Once defined, files and folders matching any of the patterns will be hidden.

{
    "files.exclude": {
        "**/*.js": true
    }
}

Hide derived resources

If you use a language that compiles to another file at the same location of the source file, like TypeScript does to JavaScript, you can easily set an expression to hide those derived files:

"**/*.js": { "when": "$(basename).ts"}

Such a pattern will match on any JavaScript file (**/*.js), but only if a sibling file with the same name and extension, *.ts in this example, is present. The same technique can be used for other transpiled languages, like Coffee Script or Less/Sass, too.

Source: VS Code v0.5.0 (July 2015)

Solution 2 - Visual Studio-Code

Although answers to this question are given, I still got tripped. So I have to give with pictures

Step #1

Click on Explorer window. This is critical as without focus on Explorer it will not work.

enter image description here

Step #2

Start Typing name you want to filter. It's weird that there is no textbox to take input but... take a leap of faith and type. You will see your typed text in top-right corner in brown background. Now hover on that text.

enter image description here

Step #3

Click on 3 stacked lines to filter..

enter image description here

They look like hamburger menu but they are not. They are saying if it's filtered or not. They are toggled between filtered and just highlight. So, make sure they are like inverted pyramid.

enter image description here

That's it. It should be filtered now.

Solution 3 - Visual Studio-Code

If you only want to change the setting for this project, then do the following:

File > Save Workspace As > ... enter your {project name}

Then open file: {project name}.code-workspace And update section settings.

Sample:

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"files.exclude": {
			"**/*.log": true
		}
	}
}

Solution 4 - Visual Studio-Code

"With the focus on the File Explorer start to type part of the file name you want to match.You will see a filter box in the top-right of the File Explorer showing what you have typed so far and matching file names will be highlighted."

"Hovering over the filter box and selecting Enable Filter on Type will show only matching files/folders."

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatija GrcicView Question on Stackoverflow
Solution 1 - Visual Studio-CodeMatija GrcicView Answer on Stackoverflow
Solution 2 - Visual Studio-CodePASView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeFieryCatView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeBotond VajnaView Answer on Stackoverflow