DEV Community

Lumin
Lumin

Posted on

2

Create VSCode User Snippet

I have enough! My VSCode always autocomplete command that I don't need when I'm about to export CommonJS module (or module.exports).

And I'm too lazy to manually type module.exports to export module in CommonJS.

To fix this, just add user snippet!

  1. Open command pallete (cmd + Shift + p)
  2. Type "user snippet" ... it should suggest "Snippets: Configure User Snippets" then hit Enter!
  3. The pallete should display a list of snippet, then choose "New Global Snippet file..." VSCode will open a new file
  4. Add this code
{
  "CommonJS export": {
    "scope": "javascript,typescript",
    "prefix": "mdep",
    "body": [
      "module.exports = {$1}"
    ],
    "description": "Export module as CommonJS"
  }
}
Enter fullscreen mode Exit fullscreen mode

What does it mean?

  • "CommonJS export" -- the name of this snippet
  • "scope": "javascript,typescript" -- this snippet will be use on JS and TS
  • "prefix": "mdep" -- I will just type mdep and got my module.exports
  • "body" -- this is the template it will generate my expected code

That's it!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)