Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>vs-excludeNew to Visual Studio Code? Get it now.
vs-exclude

vs-exclude

wmem

|
1 install
| (0) | Free
Generate files.exclude from compile_commands.json and custom keep rules.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

vs-exclude

根据 compile_commands.json 和工作区配置自动重建 files.exclude,适合 Linux 内核这类文件量很大的工程。

文档导航

  • 文档总览
  • 配置说明
  • 生成流程
  • 模块说明

配置

推荐在 .vscode/settings.json 中使用对象配置:

{
  "vsExclude.config": {
    "header": true,
    "include": [
      "drivers/net/**",
      "include/linux/**/*.h"
    ],
    "exclude": [
      "**/test/**"
    ],
    "compileCommandsPath": "build/compile_commands.json"
  }
}

字段说明:

  • header: 为 true 时,保留 compile_commands.json 中 include 搜索目录下的 .h 文件。
  • include: 额外保留的文件 glob。
  • exclude: 直接写入 files.exclude 的 glob,同时也会让这些文件不再被视为保留文件;如果某个目录已被这些规则整体覆盖,扫描阶段会直接跳过该目录。
  • compileCommandsPath: 可选,自定义 compile_commands.json 路径;未设置时默认尝试工作区根目录。

兼容旧配置:

{
  "vsExclude.header": true,
  "vsExclude.include": [],
  "vsExclude.exclude": [],
  "vsExclude.compileCommandsPath": ""
}

旧命名空间也仍然兼容:

{
  "vscodeExclude.header": true,
  "vscodeExclude.include": [],
  "vscodeExclude.exclude": [],
  "vscodeExclude.compileCommandsPath": ""
}

对象配置会优先于旧的拆分配置。

使用

  1. 打开目标工作区。
  2. 在命令面板执行 vs-exclude: Generate files.exclude。
  3. 若想查看执行日志,运行 vs-exclude: Show Log。

行为说明

  • 每次执行都会直接覆盖工作区级 files.exclude。
  • 插件会直接更新 .vscode/settings.json 中的 files.exclude,但会保留其他设置项不变。
  • 写回时会把 settings.json 规范化成标准 JSON 文本,因此原有注释和局部格式可能会被重写。
  • 若指定路径和根目录都没有 compile_commands.json,则只按 include / exclude 计算。
  • 当某个目录整棵子树都应隐藏时,会直接生成目录级排除规则,而不是逐文件写入。
  • 配置中的 exclude 规则会原样写入 files.exclude,不会再被扫描结果展开成大量单文件项。
  • 扫描工作区时会优先检查目录是否已被 exclude 规则整体覆盖;命中的目录会直接跳过,适合 node_modules 这类超大目录。
  • 生成命令执行时会弹出等待提示,并显示当前阶段,减少长时间扫描时的不确定感。
  • 长时间扫描时也可通过 vs-exclude: Show Log 查看详细日志。
  • .vscode/settings.json 会被强制保留,避免生成后无法继续修改扩展配置。

开发

npm install
npm run compile
npm test

在 VS Code 中按 F5 可启动扩展开发宿主。

打包与离线安装

生成离线安装包:

npm install
npm run package:vsix

打包成功后会在项目根目录生成 .vsix 文件,例如 vs-exclude-0.0.1.vsix。

离线安装方式:

code --install-extension vs-exclude-0.0.1.vsix

也可以在 VS Code / Cursor 的扩展页中选择 Install from VSIX... 手动安装。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft