How Do I Hide Certain Files from the Sidebar in Visual Studio Code?
In Visual Studio Code, What Setting Can Be Configured, Using File Patterns, to Hide Files from View in the Sidebar's File-Explorer? I Would Like to Hide...
In Visual Studio Code, what setting can be configured, using file patterns, to hide files from view in the sidebar's file-explorer?
I would like to hide certain groups of files, like .meta and .git files.
12 Answers
You can configure patterns to hide files and folders from the explorer and searches.
- Open VS User Settings (Main menu:
File > Preferences > Settings). This will open the setting screen. - Search for
files:excludein the search at the top. - Configure the User Setting with new glob patterns as needed. In this case add this pattern
node_modules/then click OK. The pattern syntax is powerful. You can find pattern matching details under the Search Across Files topic.
When you are done it should look something like this:
If you want to directly edit the settings file: For example to hide a top level node_modules folder in your workspace:
"files.exclude": {
"node_modules/": true
}
To hide all files that start with ._ such as ._.DS_Store files found on OSX:
"files.exclude": {
"**/._*": true
}
You also have the ability to change Workspace Settings (Main menu: File > Preferences > Workspace Settings). Workspace settings will create a .vscode/settings.json file in your current workspace and will only be applied to that workspace. User Settings will be applied globally to any instance of VS Code you open, but they won't override Workspace Settings if present. Read more on customizing User and Workspace Settings.
Sometimes you just want to hide certain file types for a specific project. In that case, you can create a folder in your project folder called .vscode and create the settings.json file in there, (i.e. .vscode/settings.json). All settings within that file will affect your current workspace only.
For example, in a TypeScript project, this is what I have used:
// Workspace settings
{
// The following will hide the js and map files in the editor
"files.exclude": {
"**/*.js": true,
"**/*.map": true
}
}
The "Make Hidden" extension works great!
Make Hidden provides more control over your project's directory by enabling context menus that allow you to perform hide/show actions effortlessly, a view pane explorer to see hidden items and the ability to save workspaces to quickly toggle between bulk hidden items.
The __pycache__ folder and *.pyc files are totally unnecessary to the developer. To hide these files from the explorer view, we need to edit the settings.json for VSCode. Add the folder and the files as shown below:
"files.exclude": {
...
...
"**/*.pyc": {"when": "$(basename).py"},
"**/__pycache__": true,
...
...
}
I would also like to recommend vscode extension Peep, which allows you to toggle hide on the excluded files in your projects settings.json.
Hit F1 for vscode command line (command palette), then
ext install [enter] peep [enter]
You can bind "extension.peepToggle" to a key like Ctrl+Shift+P (same as F1 by default) for easy toggling. Hit Ctrl+K Ctrl+S for key bindings, enter peep, select Peep Toggle and add your binding.
For .meta files while using Unity3D, I found the best pattern for hiding is:
"files.exclude": {
"*/**/**.meta": true
}
This captures all folders and subfolders, and will pick up foo.cs.meta in addition to foo.meta
If you're using VSCode:
- File > Preferences > Settings
- Search for:
files:exclude
- Then add
**/node_modules
- Click
OK.
You shouldn't need to restart or reload VSCode to take effect
If your working on a Angular 2+ application, and like me you like a clean working environment, follow @omt66 answer and paste the below in your settings.json file. I recommend you do this once all the initial setup has been completed.
Note: This will actually hide the .vscode folder (with settings.json) in as well. (Open in your native file explorer / text editor if you need to make changes afterwards)
{
"files.exclude": {
".vscode":true,
"node_modules/":true,
"dist/":true,
"e2e/":true,
"*.json": true,
"**/*.md": true,
".gitignore": true,
"**/.gitkeep":true,
".editorconfig": true,
"**/polyfills.ts": true,
"**/main.ts": true,
"**/tsconfig.app.json": true,
"**/tsconfig.spec.json": true,
"**/tslint.json": true,
"**/karma.conf.js": true,
"**/favicon.ico": true,
"**/browserslist": true,
"**/test.ts": true
}
}
Must Read
VS Code's File Nesting Feature
See the GIF below
I answered this question, with File-nesting as an answer a month or two ago, however, the feature wasn't actually released yet, but today the "VS Code File Nesting Feature" released officially.
It's one of the cooler features released in the past 6 months or so, for sure. I took the time to create a gif, which shows the configuration I used to get the functionality that the gif demonstrates. Ill also go over each available setting.
The GIF you see below shows File-Nesting, and How it works.
The gif shows a folding control that is able to toggle files in & out of view (one might say that it hides them, which would be an accurate statement). However, it does this without a directory. The question at this point is HOW? How does it know which to hide?
File-nesting has to be configured. You got to add the settings you see in my settings.json file on the right side of the GIF, but before you go watch the GIF again, lets go over each file nesting setting below.