How do I hide certain files from the sidebar in Visual Studio Code?
使用Microsoft的Visual Studio代码,如何隐藏某些文件和文件模式以免它们出现在边栏中?
我想隐藏
您可以配置模式以隐藏资源管理器和搜索中的文件和文件夹。
完成后,它应如下所示:
如果要直接编辑设置文件:
例如,在工作区中隐藏顶级node_modules文件夹:
1 2 3 | "files.exclude": { "node_modules/": true } |
要隐藏所有以._开头的文件,例如OSX上的._。DS_Store文件,请执行以下操作:
1 2 3 | "files.exclude": { "**/._*": true } |
您还可以更改工作区设置(主菜单:文件>首选项>工作区设置)。工作区设置将在您当前的工作区中创建一个
有时,您只想隐藏特定项目的某些文件类型。在这种情况下,您可以在项目文件夹中创建一个名为
例如,在TypeScript项目中,这就是我所使用的:
1 2 3 4 5 6 7 8 | // Workspace settings { // The following will hide the js and map files in the editor "files.exclude": { "**/*.js": true, "**/*.map": true } } |
对于使用Unity3D时的
1 2 3 | "files.exclude": { "*/**/**.meta": true } |
这将捕获所有文件夹和子文件夹,并且除了
"隐藏"扩展非常好!
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.
我还想推荐vscode扩展名Peep,它允许您在项目settings.json中切换隐藏文件的隐藏。
按下F1以获得vscode命令行(命令选项板),然后
1 | ext install [enter] peep [enter] |
您可以将" extension.peepToggle"绑定到Ctrl + Shift + P之类的键(默认情况下与F1相同)以方便切换。按Ctrl + K Ctrl + S进行按键绑定,输入
开发人员完全不需要
1 2 3 4 5 6 7 8 | "files.exclude": { ... ... "**/*.pyc": {"when":"$(basename).py"}, "**/__pycache__": true, ... ... } |
如果您正在使用Angular 2+应用程序,并且像我一样喜欢一个干净的工作环境,请遵循@ omt66答案并将以下内容粘贴到settings.json文件中。
我建议您在完成所有初始设置后执行此操作。
注意:这实际上也会同时隐藏.vscode文件夹(带有settings.json)。 (如果您之后需要进行更改,请在本机文件浏览器/文本编辑器中打开)
https://pastebin.com/X2NL6Vxb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | { "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 } } |