5

How to add a comment tag in HTML using Emmet in VSCode?

What I want: Before:

<div class='abc'>

After using Emmet keyboard shortcut:

<div class='abc'> <!-- -->
Alireza tk
  • 468
  • 1
  • 7
  • 25
Kushal Kumar
  • 174
  • 1
  • 13
  • Click (Ctrl + K C) to comment the html. –  Aug 28 '20 at 08:23
  • Do you see this [question](https://stackoverflow.com/questions/37312056/visual-studio-code-comment-in-html-files)? –  Aug 28 '20 at 08:24
  • The problem is that when I click after the closing tag and press Ctrl + K C, it comments out the whole line including the div, like this: The Ctrl KC only works for empty lines. Anyways I found a solution that works. I'll add it as an answer then for future seekers. The shortcut is shift+option+a but I dont know if its emmet or vscode inbuilt. – Kushal Kumar Aug 28 '20 at 08:30

2 Answers2

11

Emmet has built-in c abbreviation which outputs comment

Sergey Chikuyonok
  • 2,626
  • 14
  • 13
0

On a mac - it is command+option+"right arrow" - allows you to place a comment on a line that already has content.