Chuck
Chuck

Reputation: 4892

Does VS Code have the ability to be controlled with a script?

There's a task I do every day multiple times.

I'm moving from component to component, doing this each time. Can VS Code be scripted so that I could, perhaps, select the three files, and have VS Code get me to the final state I want?

Upvotes: 1

Views: 45

Answers (2)

rioV8
rioV8

Reputation: 28663

I have written an extension command for that, and more: File Group Scripts

Your use case could be scripted with the following setting:

  "fileGroup.scripts": {
    "open side by side (HTML,CSS,*)": {
      "script": [
        { "command": "workbench.action.focusFirstEditorGroup" },
        { "file": "all;\\.x?html$",
          "command": "htmlRelatedLinks.openFile",
          "args": { "file": "${file}"}
        },
        { "command": "workbench.action.focusSecondEditorGroup" },
        { "file": "all;\\.css$",
          "command": "htmlRelatedLinks.openFile",
          "args": { "file": "${file}"}
        },
        { "command": "workbench.action.focusThirdEditorGroup" },
        { "file": "all",
          "command": "htmlRelatedLinks.openFile",
          "args": { "file": "${file}"}
        }
      ],
      "interval": 500
    }
  }

Upvotes: 1

carlfriedrich
carlfriedrich

Reputation: 4019

You could save each combination of files as a workspace (File -> Save Workspace As... / Workspaces: Save Workspace As... command) and switch between those.

Workspaces appear in the "recently opened" list, so they can be easily recalled by pressing Ctrl+R.

Upvotes: 0

Related Questions