Visual Studio代码键绑定-使用一个快捷方式运行两个或多个命令 [英] visual studio code keybindings - Running two or more commands with one shortcut

查看:183
本文介绍了Visual Studio代码键绑定-使用一个快捷方式运行两个或多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS代码中具有以下按键绑定,可在活动文档和内置终端之间切换光标的位置:

I have the following keybinding in VS code which toggles the position of the cursor between the active document and built-in terminal:

  // Toggle between terminal and editor focus
{
    "key": "oem_8",
    "command": "workbench.action.terminal.focus"
},
{
    "key": "oem_8",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "terminalFocus"
}

在我单击快捷键将光标移动到终端之前,我首先必须保存活动文件.

Before i click the shortcut key to move the cursor to the terminal, i first have to save the active file.

因此,我想运行文件保存命令,在Google上搜索后,我相信它是:workbench.action.files.save

I would therefore like to run the file saving command, which after searching on google i believe is :workbench.action.files.save

请问我该怎么做?我尝试在命令"行的末尾添加上述代码片段,但没有用.

How would i do this please? i have tried adding the above code snippet at the end of the "command" line but it has not worked.

欢呼

推荐答案

您将需要扩展名,例如

You would need an extension like macros to run multiple commands from one keybinding.

在您的settings.json中:

In your settings.json:

"macros": {
      // give it whatever name you what
      "saveAndFocusTerminal" : [
          "workbench.action.files.save",
          "workbench.action.terminal.focus"
      ]
}

并在您的keybindings.json中:

and in your keybindings.json:

{
    "key": "oem_8",
                // use your name from above here
    "command":  "macros.saveAndFocusTerminal"
},

我不再使用macros扩展名,它没有得到维护,缺少一些关键功能.我现在使用多命令,并且现在还有其他宏扩展.

I don't use the macros extension anymore, it hasn't been maintained and is missing some crucial functionality. I now use multi-command and there are other macro extensions now.

这篇关于Visual Studio代码键绑定-使用一个快捷方式运行两个或多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆