如何排除vscode中除一个文件夹之外的所有文件夹? [英] How to exclude all folders except one folder in vscode?

查看:101
本文介绍了如何排除vscode中除一个文件夹之外的所有文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

└── target
    ├── W350
    ├── W400
    ├── W600
    ├── W600_HW_V2
    ├── W600_KT_HW_V2
    ├── W600_KT_HW_V2_neutral
    ├── W600_TK
    ├── W650
    ├── W650_HW_V2
    └── W750

我想排除除 W600_KT_HW_V2 之外的所有文件夹.然后 VSCode 应该显示这棵树:

I want to exclude all folders except W600_KT_HW_V2. VSCode should then show this tree:

└── target
    └── W600_KT_HW_V2

我该怎么办?

推荐答案

一般来说,你可以这样做:

In general, you could do this:

"files.exclude": {
  //  "**/node_modules": true,

  "**/[^1]*": true,    // all you need in your example
  "**/1[^2]*": true,
  "**/12[^3]*": true
},

在您的情况下,只需要第一个 "**/[^1]*": true, .如果您还希望排除像 1abc 这样的文件夹,则会使用额外的行.你走多远取决于你的文件夹名称的相似性.但是您没有详细说明您的用例有多复杂.

In your case, only the first "**/[^1]*": true, would be needed. The additional lines would be used if you had folders like 1abc that you also want excluded. How deep you go depends on the similarity of your folder names. But you don't give a lot of detail on how complicated your use case is.

但是你看到了模式.Vscode 不支持 !files.exclude 中的否定,因此您必须使用 [^x] 表单排除除您想要的之外的所有内容.

But you see the pattern. Vscode doesn't support ! negation in files.exclude so you have to exclude everything but what you want with the [^x] form.

更新文件结构后,它看起来像这样:

After you updated your file structure, it looks like this works:

"files.exclude": {
  "**/[^W]*": true,
  "**/W[^6]*": true,
  "**/W6[^0]*": true,

  "**/W600": true,         // the only one I had to "hardcode"
  "**/W600_[^K]*": true,
  "**/W600_KT_HW_V2_*": true
}

考虑到您想要的唯一文件夹与要排除的文件夹有多相似,这还不错.您可以在两个示例中看到一般模式 - 在之前排除类似文件夹后,我能够消除一些中间体.

which isn't too bad considering how similar the only folder you want is to those to be excluded. You can see the general pattern in the two examples - I was able to eliminate a few of the intermediates after similar folders were excluded earlier.

另见 如何在 Visual Studio Code 的侧边栏中排除除某些文件之外的所有文件? 使用文件扩展名执行此操作.

Also see How to exclude all but certain files in the sidebar in Visual Studio Code? for doing this with file extensions.

这篇关于如何排除vscode中除一个文件夹之外的所有文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆