And*_*rey 227 visual-studio-code
我正在尝试在Visual Studio代码中的"浏览"选项卡上排除多个文件夹.为此,我在项目的根目录中添加了以下jsconfig.json:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
但是"node_modules"文件夹仍然在目录树中可见.我究竟做错了什么?还有其他选择吗?
Wos*_*osi 411
workspace settings标签将此代码添加到settings.json右侧显示的文件中:
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"**/.git": true, // this is a default value
"**/.DS_Store": true, // this is a default value
"**/node_modules": true, // this excludes all folders
// named "node_modules" from
// the explore tree
// alternative version
"node_modules": true // this excludes the folder
// only from the root of
// your workspace
}
}
Run Code Online (Sandbox Code Playgroud)如果选择" 文件" - >"首选项" - >"用户设置",则可以为当前用户全局配置排除文件夹.
Dre*_*kes 76
在较新版本的VS Code中,您可以导航到设置(Ctrl+ ,),并确保选择右上角的" 工作区设置".
然后添加一个files.exclude选项以指定要排除的模式.
search.exclude如果您只想从搜索结果中排除文件,而不是从文件夹资源管理器中排除文件,也可以添加.
tot*_*dli 25
settings.json:{}图标以打开settings.json:

将排除的文件夹添加到中files.exclude。还要检查一下search.exclude,files.watcherExclude因为它们可能也很有用。此代码段包含其说明和默认值:
{
// Configure glob patterns for excluding files and folders. For example, the files explorer decides which files and folders to show or hide based on this setting. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
// Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the `files.exclude` setting. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options).
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true
},
// Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths (i.e. prefix with ** or the full path to match properly). Changing this setting requires a restart. When you experience Code consuming lots of cpu time on startup, you can exclude large folders to reduce the initial load.
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
}
}
Run Code Online (Sandbox Code Playgroud)有关其他设置的更多详细信息,请参见官方settings.json参考。
在Visual Studio版本1.28中,"files.exclude"必须将代码放在settings节点内。
生成的工作空间文件如下所示:
{
"settings": {
"files.exclude": {
"**/node_modules": true
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个资源管理器排除扩展正是可以做到这一点。https://marketplace.visualstudio.com/items?itemName=RedVanWorkshop.explorer-exclude-vscode-extension
它添加了一个隐藏当前文件夹/文件的选项到右键菜单。它还在资源管理器菜单中添加了一个垂直选项卡“隐藏项目”,您可以在其中查看当前隐藏的文件和文件夹,并可以轻松切换它们。
| 归档时间: |
|
| 查看次数: |
101725 次 |
| 最近记录: |