Search code examples
visual-studio-codevscode-tasks

There is any way to run task directy, with skipping task prompt?


Like in title, is there any way to run task with skipping task prompt?

My keybindings.json, and tasks.json:

{
    "key": "f4",
    "command": "workbench.action.tasks.runTask",
    "args": "echo"
}
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo Hello",
            "problemMatcher": []
        }
    ]
}

And everything works fine, except when I click f4 the prompt Select the task to run appear where I have to click Enter to run task. I want to run task directly skipping the prompt step.

I know why this happens because runTask:

workbench.action.tasks.runTask - Run Task

args - Filters the tasks shown in the Quick Pick

Is there any hack?


Solution

  • File keybindings.json created in .vscode folder in your project directory will not work.

    Make sure you edit right keybindings.json file, which is located at C:\Users\***\AppData\Roaming\Code\User\keybindings.json.