How can I run a custom task (different from test o

2019-01-26 18:10发布

I know I can assign a keychord to 2 standard tasks: build and test in VSCode. I need to do the same with a custom task. How can I do it?

3条回答
唯我独甜
2楼-- · 2019-01-26 18:18

As the other answer says, you currently cannot. But until it is fixed, there is a ...

Workaround using AutoHotKey:

Run fixed command line using keyboard shortcut:

^!1::Run mytask.exe myfile.txt

The above one launches command line mytask.exe myfile.txt on pressing Ctrl+Alt+1.

If you want to limit scope of the shortcut from global to VSCode only, add #IfWinActive directive before that line.

Of course, you can also expand the macro to determine the file dynamically (or from user input) but I wanted to show you some minimum example which is a way to go.

查看更多
做自己的国王
3楼-- · 2019-01-26 18:24

Use runTask with args.

{
    "key": "shift+cmd+t",
    "command": "workbench.action.tasks.runTask",
    "args": "The name of your task"
}
查看更多
相关推荐>>
4楼-- · 2019-01-26 18:31

You can't currently. Here is the github issue with the feature request. Looks like it keeps getting pushed to 'the next' release.

查看更多
登录 后发表回答