JavaScript and typescript shared snippets in vscode
Asked Answered
L

1

10

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)

Lagasse answered 17/1, 2019 at 23:15 Comment(0)
P
25

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);",
},
Peculiarity answered 18/1, 2019 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.