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

here's the code in keybindings.json of vscode, but it is not working as expected! Just saving the file and not sending "r" to the terminal

I tried everything and I just want it to do both

  1. save the file
  2. send r to terminal
11
  • why do you need to send r to terminal tho?
    – Dimava
    Commented Sep 28, 2023 at 22:35
  • to reload the app Commented Sep 28, 2023 at 22:40
  • Can you use a file watcher like chokidar instead?
    – Dimava
    Commented Sep 28, 2023 at 22:41
  • ...actually I remember there was extention to run things on file save
    – Dimava
    Commented Sep 28, 2023 at 22:42
  • Would marketplace.visualstudio.com/… work for you?
    – Dimava
    Commented Sep 28, 2023 at 22:42

1 Answer 1

0

The issue was to pass the args to a specific command while using mutliple commands

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.