24

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?

Animated GIF

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Leo Salayog
  • 241
  • 2
  • 7

7 Answers7

16

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.

Artanis
  • 965
  • 1
  • 7
  • 25
11

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.

Disable all extensions

anjandash
  • 797
  • 10
  • 21
  • 4
    This 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
  • Same here thanks for commenting this saved me some time. – Mark B Tomlinson Nov 21 '22 at 15:43
  • 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
7

In case it helps anyone else, it was the Go extension that changed all my comment characters to {#.

HTH

Martin Dimmock
  • 103
  • 2
  • 8
6

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!

Igor Escodro
  • 1,307
  • 2
  • 16
  • 30
Jim W
  • 81
  • 2
  • 5
1

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.

alwaysask
  • 111
  • 3
0

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.

Suraj Soni
  • 11
  • 2
0

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.

Megrax
  • 103
  • 6