Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Comment InserterNew to Visual Studio Code? Get it now.
Comment Inserter

Comment Inserter

Tony.Ji

|
1 install
| (0) | Free
状态栏 Comment 按钮 + 可配置/可追加的注释片段插入,支持 {#date} 变量。
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Comment Inserter

简洁的“注释片段一键插入”扩展:状态栏提供 Comment 按钮,或使用命令与快捷键快速插入多语言可配置的注释块;支持语言 / 扩展名专属覆盖、自定义选项持久化、日期变量 {#date}、一键生成快捷键片段与调试/转储配置。

✨ 特性概览

  1. 状态栏按钮:一键呼出菜单。
  2. 6 个内置动作:ADD START / ADD END / MOD START / MOD END / DEL START / DEL END。
  3. 语言/扩展名特定配置:如 texts.addStart.py、texts.addStart.ts 优先于通用 texts.addStart。
  4. 支持多行模板(设置项使用数组)与动态变量 {#date}(格式可定制)。
  5. “+追加” 可新增任意自定义注释片段(持久化存储,可删除)。
  6. 生成快捷键片段:自动读取配置中保存的虚拟快捷键并复制到剪贴板。
  7. 调试支持:输出候选键与命中;命令快速查看当前文件解析结果;完整配置转储。
  8. 零侵入:不修改现有文件,只在光标处插入文本。

🧩 主要命令

在命令面板 (Ctrl+Shift+P) 输入:

  • Comment: 显示菜单 (commentInserter.showMenu)
  • Comment: 新增自定义选项 (commentInserter.addCustomOption)
  • Comment: 管理自定义选项 (commentInserter.manageCustomOptions)
  • Comment: 生成快捷键设置片段 (commentInserter.generateKeybindingsSnippet)
  • Comment: 调试当前文件使用的配置键 (commentInserter.debugCurrentResolution)
  • Comment: 转储全部配置与命中 (commentInserter.dumpConfig)

插入内置片段命令:

  • commentInserter.insert.addStart
  • commentInserter.insert.addEnd
  • commentInserter.insert.modStart
  • commentInserter.insert.modEnd
  • commentInserter.insert.delStart
  • commentInserter.insert.delEnd

⚙️ 配置要点

所有配置前缀:commentInserter.*

内置片段文本(数组 => 多行):

commentInserter.texts.addStart
commentInserter.texts.addEnd
commentInserter.texts.modStart
commentInserter.texts.modEnd
commentInserter.texts.delStart
commentInserter.texts.delEnd

语言/扩展名专用覆盖示例:

commentInserter.texts.addStart.py
commentInserter.texts.addStart.ts
commentInserter.texts.addStart.java

解析优先级(从高到低):languageId 覆盖键 -> 扩展名覆盖键 -> 通用键。

日期变量:模板中 {#date} 按 commentInserter.dateFormat 替换,支持占位:YYYY / MM / DD。

调试日志:commentInserter.logging.enable=true 后在 Output 面板选择 “Comment Inserter” 查看解析过程。

🧪 示例设置

{
  "commentInserter.texts.addStart": ["/* ADD START {#date} */"],
  "commentInserter.texts.addStart.py": ["# ADD START {#date}"],
  "commentInserter.dateFormat": "YYYY/MM/DD"
}

⌨️ 快捷键

扩展内已默认绑定 Ctrl+Alt+1~6,可自行在 keybindings.json 重写。

自动生成片段:运行命令 “Comment: 生成快捷键设置片段” 后粘贴到 keybindings.json。

➕ 自定义选项

  1. 点击状态栏按钮 -> 选择 “+追加”
  2. 输入名称、文本(可含 {#date})、可选快捷键(仅用于生成片段)
  3. 通过 “Comment: 管理自定义选项” 删除

🔍 调试 & 诊断

  • “Comment: 调试当前文件使用的配置键” 弹出首行预览
  • “Comment: 转储全部配置与命中” 输出所有配置值 + 当前文件判定
  • 打开 commentInserter.logging.enable 查看语言候选与命中路径

🖼️ 图标

icon.png 为手工准备的静态 256x256 PNG(根目录)。如需替换:保持透明背景、正方形、大小 ≤ 512KB。

🛠️ 开发

npm install
npm run watch

VS Code 调试面板选择 “Run Extension”。

发布前会执行 npm run compile(由 vscode:prepublish 钩子触发)。

📝 1.0.0 版本说明

  • 首个稳定版本
  • 新增:快捷键片段生成命令、调试命令、配置转储命令
  • 改进:语言/扩展名解析日志、README 细化、图标脚本

📄 许可证

MIT

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