4

即使使用默认配置,在进行工作区搜索时,我仍然会在各种 node_modules 文件夹中获得大量结果。

默认设置:

"search.excludeFolders": [
        ".git",
        "node_modules",
        "bower_components"
    ],

我什至尝试复制到我的用户设置并更改为多个变体,例如“/node_modules”、“/node_modules/”等。

我已经在 vscode 中看到过关于此问题的另一篇文章:如何选择在搜索期间忽略的文件夹?. 这个答案不能解决我的问题。

我在 OS X 上使用 0.1.0 版(提交 d13afe1)。排除文件夹是否有错误?

4

2 回答 2

3

在再次阅读您的问题并尝试之后,我才注意到这些search.excludeFolders值仅适用于工作区根目录。因此,对于node_modules层次结构中的文件夹,您需要使用:

{
    "search.excludeFolders": [
        ".git",
        "node_modules",
        "bower_components",
        "path/to/node_modules"
    ]
}
于 2015-04-30T20:37:42.973 回答
2

自@alex-dima 的回答以来,这些偏好似乎已经改变。

App -> Preferences -> User/Workspace Settings

您可以选择将应用于搜索的自定义设置。例如,我正在开发一个 EmberJS 应用程序,它在tmp目录下保存了数千个文件。

更新设置前的搜索图片。 更新设置前的搜索图片。]

更新 Visual Studio 设置后。

{
    "search.exclude": {
        "**/.git": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/tmp": true
    }
}

注意:在任何搜索排除的开头包含一个 **,以涵盖任何文件夹和子文件夹中的搜索词。

搜索结果正是我想要的。

更新设置后的搜索图片。 更新设置后的搜索图片。

于 2015-10-29T16:33:35.740 回答