I recently used VS code for Wordpress development but I encountered a weird bug when I comment with (ctrl+/) to an html element. Instead of commenting (<!-- -->
) it uses (//
) for my html code? Has anybody experience this? Do you know of any solutions to change the comment to the correct html comment?

- 142,137
- 41
- 261
- 360

- 241
- 2
- 7
-
See gif attachment for clarification. – Leo Salayog Jul 01 '17 at 06:41
-
Possible duplicate of [Visual studio code comment in HTML files](https://stackoverflow.com/q/37312056/11683) – GSerg Jul 01 '17 at 07:01
7 Answers
This is caused by VS Code improperly auto-detected programming language - in the lower right corner of your GIF you can clearly see, that VS Code is set to HTML. Click on that button, and switch over to JavaScript (React) and problem should be solved.

- 965
- 1
- 7
- 25
I had the same exact problem. But in the end, I discovered I had an extension which was interfering with the HTML commenting. So I had to disable all extensions and restart VS Code to get back to my usual commenting back again.
Then I did a trial-and-error check (enabling one extension at a time and then reload) to find out the faulty extension which I later uninstalled. Try disabling all your extensions to see if it helps you.

- 797
- 10
- 21
-
4This was the case for me. I had these comment because of the "Hugo Language and Syntax Support" Extension in regular .html files – JiiB Aug 24 '21 at 12:53
-
-
So, this issue is known since pretty much exactly two years & the extension still was not fixed? Wow. Just wow. Had to disable the Hugo extension & now it works! – Akito Aug 29 '23 at 13:57
In case it helps anyone else, it was the Go extension that changed all my comment characters to {#.
HTH

- 103
- 2
- 8
For future searchers, this happened to me in a different way: I was getting HTML comments inside a script tag, instead of JavaScript comments.
I disabled the TWIG
pack extension and it went back to the expected behavior!

- 1,307
- 2
- 16
- 30

- 81
- 2
- 5
In my case it was the Sublime Babel
extension that changed the comment code to //
in HTML mode. Downgrading Sublime Babel
from 0.2.10 to 0.2.9 solved the issue.

- 111
- 3
In my case I was getting html comments inside script tag, instead of Javascript tag.
I uninstalled Jinja
extension and everything went back to normal.

- 11
- 2
In my case it is the Hugo Language and Syntax Support
plugin that breaks my HTML commenting: https://github.com/theNewDynamic/language-hugo-vscode/issues/26.

- 103
- 6