You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VSCode中查找命令标识符?含调试启动命令标识查询

如何查找VSCode命令标识符(附Debug命令ID)

我经常在扩展开发里碰到这个需求,给你分享两个靠谱的通用方法,以及你要的Debug: Start Debugging的标识符:

通用查找方法

方法一:命令面板快速查看(最简便)

这是我平时用得最多的方式,完全不用碰代码:

  • 按下Ctrl+Shift+P打开命令面板
  • 找到你目标命令的标题(比如Debug: Start Debugging)
  • 按住Ctrl键(Mac系统换成Cmd键),这时候命令标题旁边会直接弹出对应的命令标识符
  • 点击这个标识符就能一键复制到剪贴板,直接用在你的扩展代码里

方法二:通过开发者工具批量查看

如果需要批量找命令或者做精准筛选,用这个方法:

  • 按下Ctrl+Shift+I(Mac是Cmd+Opt+I)打开VSCode的开发者工具
  • 在控制台里输入这段代码并回车,就能列出所有已注册的命令标识符:
    vscode.commands.getCommands(true).then(commands => commands.forEach(cmd => console.log(cmd)));
    
  • 要是想只看某一类命令(比如Debug相关),可以改成过滤逻辑:
    vscode.commands.getCommands(true).then(commands => {
      const debugCmds = commands.filter(cmd => cmd.startsWith('debug'));
      debugCmds.forEach(cmd => console.log(cmd));
    });
    

Debug: Start Debugging的命令标识符

你要的这个命令的标识符是debug.startDebugging,在扩展里调用它的示例TypeScript代码如下:

import * as vscode from 'vscode';

// 在你的扩展逻辑中调用
async function triggerDebug() {
  await vscode.commands.executeCommand('debug.startDebugging');
}

内容的提问来源于stack exchange,提问作者Nurbol Alpysbayev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:19:12