Reputation: 143
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
Reputation: 181569
See this extension written by me, Toggle Line Comments, that will do what you want.
-- or older answer --
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.
Shift-Alt-I will put a cursor at the end of each line.
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