VSCode on Github has an issue titled Running commands as tasks #11396
. It involves running a VSCode command as an internal task in VSCode.
alexr00 commented on Dec 20, 2018 that
:
You can now have commands in tasks.json
and points to the following docs:
https://code.visualstudio.com/docs/editor/variables-reference#_settings-command-variables-and-input-variables
I've read through these docs and I am still unable to figure out how to do what I want. For starters, I'd like to create a simple task that runs the liveserver extention start code: extention.liveServer.goOnline
Anyone have any thoughts on what to try or where to look?
Tip: You can run your task through Quick Open (Ctrl+P) by typing 'task', Space and the command name. In this case, 'task lint'.
So for instance you could do this:
{
"label": "run copyLinesDown command",
// "type": "shell",
"command": "${command:editor.action.copyLinesDownAction}",
// "command": "${command:extension.gist.open}" // etc
// "runOptions": {
// "runOn": "folderOpen"
// }
},
That is a task in tasks.json
. When you run that task, the current line in the active editor will be copied down.
So I presume if you used
"command": "${command:extension.liveServer.goOnline}",
in a task like the above that extension command should be run. (Check the spelling, is it extention
or extension
?)
See specifically command variables.
And then you can assign a keybinding to that task with (in keybindings.json):
{
"key": "ctrl+h", // binding of your choice
"command": "workbench.action.tasks.runTask",
"args": "run copyLinesDown command"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With