How would you filter the files shown in the folder view in Visual Studio Code?
Reference: Filter files shown in folder
How would you filter the files shown in the folder view in Visual Studio Code?
Reference: Filter files shown in folder
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)
In version after VScode 1.70 (July 2022) all you need to do is
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
}
}
}
VScode 1.70 (July 2022) should improve on this "tree filter" feature.
(Available today in Code insiders)
See issue 70646 and PR 152481:
Support find widget in lists/trees
This PR replaces the existing list/tree type filter:
with an bona fide
find
widget:
While a seemingly simple change, this has some (desired) consequences when searching/filtering in trees. Namely:
- We will restore simple keyboard navigation by default.
That is: pressing the letter A will focus the next element which starts withA
.- Initiating a search operation requires pressing Ctrl-F or F3, like the editor.
- While searching, focus is in the find input box as opposed to the list itself.
Pressing DownArrow will focus the first list element which was found.- We'll preserve all custom behavior of context keys, eg. used by the VIM extension).
In VIM, the pre-existing / command will trigger simple keyboard navigation, as opposed to opening the find widget.
The VIM extension has the option to change this behavior themselves.
And:
In general:
Keyboard navigation
is now calledtype navigation
Filter on type
is now calledfind mode
, aligned with a newfind
conceptSettings
workbench.list.keyboardNavigation
has been renamed toworkbench.list.defaultFindMode
workbench.list.automaticKeyboardNavigation
has been deletedCommands
list.toggleKeyboardNavigation
has been renamed tolist.triggerTypeNavigation
list.find
has been addedlist.closeFind
has been addedlist.toggleFilterOnType
has been renamed tolist.toggleFindMode
Context Keys
Mainly used by the vim extension:
listSupportsKeyboardNavigation
has been renamed tolistSupportsTypeNavigation
listAutomaticKeyboardNavigation
has been renamed tolistTypeNavigationMode
"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
This doesn't exactly answer your question as it is stated, because there just isn't a way to do that afaik.
However, if you want to locate a particular file within the opened folder, given a partial name or its extension: the best way to do that is to use Ctrl+P
and start typing.
Example: note it is showing .xml files with the string faction in its name
I have tried several times to make use of the explorer panel, and always come to the conclusion id rather use windows explorer (which you can quickly get to by via right click and open folder on an open document tab).