DEV Community

Drozerah
Drozerah

Posted on

3

VSCode Snippet your ES6 template literals!

code
The more you use ES6 template literals into your console.log() - like I do -, the more you need your VSCode snippet! Do not repeat yourself writing the same template!

const greetings = "Hello"
console.log(`${greetings} the DEV community!`) // Hello the DEV community!
Enter fullscreen mode Exit fullscreen mode

Creating your own snippet with VSCode is easy:

VSCode > File > Preferences > User Snippets > New Global Snippets file

then, select the language you want the snippet to be available for, JavaScriptin our case, copy and past your snippet syntax as .json format:

{}javascript.json VSCode file

//...
"Template literals to console": {
    "prefix": "clgt",
    "body": [
        "console.log(` ${$0}`)"
    ],
    "description": "Template literals to console"
}
//...
Enter fullscreen mode Exit fullscreen mode

This is it !

Now, in any .js file you are working on, simply type the snippet prefix clgt an press Tab to insert a new snippet into your code. Don't forget to enable the tab completion of your editor first "editor.tabCompletion": "on".

Tip => snippet generator

Next step?

Have fun & Be creative!

Thanks for reading!

See you next time!

Drozerah

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay