将“r”发送到终端并在按下“Ctrl + S”时保存文件

问题描述 投票:0回答:1
{
    "key": "ctrl+s",
    "command": "runCommands",
    "args": {
        "commands": [
            "workbench.action.terminal.sendSequence",
            "workbench.action.files.save"
        ],
        "text": "r"
    },
    "when": "editorTextFocus && !editorReadonly"
}

这是vscode的keybindings.json中的代码,但它没有按预期工作! 仅保存文件而不将“r”发送到终端

我尝试了一切,我只想两者兼得

  1. 保存文件
  2. 将 r 发送到终端
visual-studio-code key-bindings
1个回答
0
投票

问题是在使用多个命令时将参数传递给特定命令

{
    "key": "ctrl+s",
    "command": "runCommands",
    "args": {
        "commands": [
            {
                "command": "workbench.action.terminal.sendSequence",
                "args": {
                    "text": "r"
                }
            },
            "workbench.action.files.save"
        ], 
    },
    "when": "editorTextFocus && !editorReadonly"
}

© www.soinside.com 2019 - 2024. All rights reserved.