【问题标题】:Is there a way to run commands available in the command palette using Visual Studio Code's API?有没有办法使用 Visual Studio Code 的 API 运行命令面板中可用的命令?
【发布时间】:2023-01-21 08:14:25
【问题描述】:

我正在构建一个 Visual Studio Code 扩展,它需要一个仅在命令面板中可用的命令(据我所知)。我希望能够使用 VS Code 的 API 在 JavaScript 中控制此命令。我正在寻找这样的东西:

vscode.commandPalette.run (A function in command palette)

【问题讨论】:

    标签: javascript vscode-extensions


    【解决方案1】:

    这个精确的场景记录在这里:https://code.visualstudio.com/api/extension-guides/command

    这是从该文档中提取的示例:

    import * as vscode from 'vscode';
    
    function commentLine() {
      vscode.commands.executeCommand('editor.action.addCommentLine');
    }
    

    【讨论】:

      猜你喜欢
      • 2018-07-08
      • 2013-11-18
      • 2011-03-29
      • 2016-06-04
      • 1970-01-01
      • 2018-05-11
      • 2017-06-06
      • 2019-07-31
      • 1970-01-01
      相关资源
      最近更新 更多