Syntax-highlighting for JS template strings in VS Code
- Published at
- Updated at
- Reading time
- 2min
Here's Remy sharing how to enable template string syntax highlighting via JavaScript comments.
The problem of unhighlighted template strings never really bugged me. I write many of this blog's interactive components without proper syntax highlighting, because I've built myself a custom mini Astro framework. And of course, like many homegrown solutions, it lacks a good developer experience. Missing syntax highlighting was never an issue, though, and things are fine.
However, now that I've read Remy's post, why not make things a little nicer to look at?
Remy describes that when using the right JS comments, Prettier and the VS Code formatter will work together to format and syntax-highlight the template string content.
Unfortunately, that didn't work in VS Code and I had to install two additional VS Code extensions:
But now I can use /* CSS */ to get some template string CSS highlighting.
And if I use HTML in template strings, it'll be highlighted and even formatted via Prettier.
That's very nice! Thank you Remy for the push!
Join 6.1k readers and learn something new every week with Web Weekly.



