11

I have created quite a lot of custom JavaScript snippets in VsCode. Recently, I started working on a project in typescript and, not unexpectedly, the JavaScript snippets do not work in typescript files.

Is there a way to create "shared" snippets that I could use both in JavaScript and typescript? (apart from copying the snippet definition files every time I create a custom snippet)

1 Answer 1

26

You can create global snippets and scope them:

  • From command palette Preferences: Configure User Snippets
  • New Global Snippets File

"console.log": {
    "scope": "typescript,javascript,typescriptreact,javascriptreact",
    "prefix": "cl",
    "body": "console.log($0);",
},
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.