Mark the task as your default build task via Terminal -> Configure Default Build Task... This simply adds the following to the task in tasks.json
:
"group": {
"kind": "build",
"isDefault": true
}
After that, Ctrl+Shift+B will run the task directly.
Additionally, you could also have a default test task with "kind": "test"
. That task can be directly run with the Tasks: Run Test Task
command (no shortcut assigned by default).
And finally, if having two shortcuts is still not enough (or you don't want to modify tasks.json
), you can set up keybindings to run tasks directly by their name:
{
"key": "ctrl+b",
"command": "workbench.action.tasks.runTask",
"args": "run"
}
Replacing run
with the label of your Build Task.
To open keybindings.json
press Ctrl+K Ctrl+S or click File -> Preferences -> Keyboard Shortcuts. You may need to add []
if the file was previously empty.
keybindings.json
? I tried adding it to my project's.vscode
folder where thetasks.json
file is, but it doesn't seem to do anything. – Pessa