vscode-code-runner
vscode-code-runner copied to clipboard
Can I use Code Runner to "run on save"?
We have two settings:
- "code-runner.saveAllFilesBeforeRun": save all files before running
- "code-runner.saveFileBeforeRun": save the current file before running
Is is enough for your?
@formulahendry I think what the author meant is to run the code every time you save the file. Is this possible?
As above, I was looking for a solution to this as well; a way to run Code Runner automatically upon saving a file (in contrast to the current implementation of saving file(s) before running Code Runner). This would also bring it closer to Quokka.js which actively updates the output upon saving the watched file.
At the moment, my workaround is to add the following macro/shortcut to VS Code's keybindings.json to simulate this requested behaviour.
{
"key": "ctrl+enter",
"command": "code-runner.run"
}
This worked well with the multicommand extension. The "clearOutput" is only because my Output doesn't scroll automatically - at least on Windows. All I want is to avoid the mouse during this kind of work session.
[
{
"key": "ctrl+r",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.action.files.save",
"workbench.output.action.clearOutput",
"code-runner.run"
]
}
}
]
The following notification pops up when the bash script isn't opened or focused:
No code found or selected.
How do I resolve this?
The following is my current settings.json file and I don't know how to make the extension run without having to have my bash script open.
{
"runOnSave.commands": [{
"match": ".*",
"command": "code-runner.run",
"runIn": "vscode"
"runningStatusMessage": "Running ${fileBasename}.",
"finishStatusMessage": "${fileBasename} completed."
}],
"runOnSave.statusMessageTimeout": 78000,
"files.autoSaveDelay": 1000,
"code-runner.cwd": "/location/to/bash/script",
"code-runner.defaultLanguage": "BASH/SH",
"code-runner.showExecutionMessage": true,
"code-runner.customCommand": "./bash-script.sh"
}