Kushal Kumar
Kushal Kumar

Reputation: 184

how do I add a comment tag in VSCode for HTML using Emmet?

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'> <!-- -->

Upvotes: 5

Views: 6781

Answers (4)

Paulocity Dev
Paulocity Dev

Reputation: 1

In VS Code, you can use the Emmet abbreviation <!-- to comment out HTML code. Here's how:

  1. Select the HTML code you want to comment out.
  2. Type <!-- (start of comment)
  3. Press Tab (or Enter on some systems)
  4. Emmet will automatically add the closing --> (end of comment)

Alternatively, you can also use the keyboard shortcut:

  • Windows/Linux: Ctrl + Shift + 8
  • Mac: Cmd + Shift + 8

This will toggle commenting out the selected HTML code.

Note: Make sure you have Emmet installed and enabled in your VS Code settings. If you're not sure, you can check the VS Code documentation or install Emmet from the Extensions marketplace.

Upvotes: 0

krenerd
krenerd

Reputation: 791

There is a command called Emmet: Toggle Comment which comments the current line. If you use the keybinding extenstion, it is configured as Cmd M + Cmd / .

<title>Document</title>
-> 
<!-- <title>Document</title> -->

Upvotes: 1

Tim Grant
Tim Grant

Reputation: 1

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

Upvotes: 0

Sergey Chikuyonok
Sergey Chikuyonok

Reputation: 2699

Emmet has built-in c abbreviation which outputs comment

Upvotes: 13

Related Questions