How can I run a VSCode command as a task

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"
    }

Leave a Comment