Julien Bongars
Julien Bongars

Reputation: 143

HTML comment each line separately, not block comments

Noob question but I want to be able to quickly comment HTML code using keyboard shortcuts in VS Code. The problem is I get this:

<!-- <div class="whatever">
        <h1>Hellow World!</h1>
        <p>this is code I wrote in HTML</p>
      </div> -->

instead of this:

<!-- <div class="whatever"> -->
   <!-- <h1>Hellow World!</h1> -->
   <!-- <p>this is code I wrote in HTML</p> -->
<!-- </div> -->

Anyone know a good extension for this in VS Code? Thanks

Julien

Upvotes: 5

Views: 1372

Answers (2)

CatBraaain
CatBraaain

Reputation: 56

I found really new extension exactly matches your needs.

Enhanced Comments demo.gif

Upvotes: 1

Mark
Mark

Reputation: 181569

See this extension written by me, Toggle Line Comments, that will do what you want.

-- or older answer --

  1. Select through your text - i.e., from some part of the first line to some part of the last line you want separately commented. I.e., highlight your block of HTML to comment.

  2. Shift-Alt-I will put a cursor at the end of each line.

  3. Ctrl-/ will comment each line separately.

This only seems necessary for HTML, not JS or SCSS for example.

I suppose if you wanted to reduce keystrokes you could make a macro for steps 2 and 3 combined.

Upvotes: 6

Related Questions