Emmet Logo Hero Image

Closing Comments in Emmet with Visual Studio Code

I recently switched from using Sublime Text as my code editor to using Visual Studio Code (VSC). There's a lot to like with VSC especially the integrated terminal and Emmet out of the box.

One thing that I was missing is having Emmet create closing comments which I had previously blogged about here.

I tried the process there but it wasn't working and after googling I found this github thread. This ultimately led to the solution that the syntax has changed in the latest version of Emmet which ships with VSC.

To get Emmet to add comments and keep them on the same line as the closing tag add the following to your user settings file in Visual Studio Code and then restart VSC.

  "emmet.preferences":{
    "filter.commentAfter": "<!-- /[#ID][.CLASS] -->",
  },
  "emmet.syntaxProfiles": {
  // Enable XHTML dialect for HTML syntax
  // “html”: “xhtml”
    "html" : {
      "filters" :"html, c"
      }
  },