2

I'm often using VS Code for Html/Css/Js development. I'm often using the following task (from other SO post) to open HTML page in browser:

{
    "version": "0.1.0",
    "command": "explorer",    
    "windows": {
        "command": "explorer.exe"
    },
    "args": ["${file}"]
}

Is there a way to add this task as default one for all folders?

1
  • I think this is an important missing feature! I have to duplicate my tasks along different folders :-( Commented Nov 26, 2019 at 9:15

1 Answer 1

1

The short answer is "no".

The slightly longer answer is, "no, but they are thinking about ways this can be done" as demonstrated in this issue.

A workaround is to add a snippet that you can easily add to tasks.json in new projects. Go to File > Preferences > User Snippets > json and add something like this:

"Explorer Task": {
    "prefix": "expTask",
    "body": [
        '{',
            '\t"version": "0.1.0",',
            '\t"command": "explorer",',    
            '\t"windows": {',
                '\t\t"command": "explorer.exe"',
            '\t},',
            '\t"args": ["${file}"]',
        '}'
    ],
    "description": "Explorer task that I use so often"
},

Now when you go to tasks.json in any new project, you type expTask (or whatever you name it) and you can easily drop this in.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.