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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Use runTask
with args
.
{
"key": "shift+cmd+t",
"command": "workbench.action.tasks.runTask",
"args": "The name of your task"
}
回答2:
You can't currently. Here is the github issue with the feature request. Looks like it keeps getting pushed to 'the next' release.
回答3:
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.