'Visual Studio Code HTML wrong comment type
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?
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
In case it helps anyone else, it was the Go extension that changed all my comment characters to {#.
HTH
Solution 4:[4]
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!
Solution 5:[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.
Solution 6:[6]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Artanis |
Solution 2 | |
Solution 3 | |
Solution 4 | Igor Escodro |
Solution 5 | alwaysask |
Solution 6 | Suraj Soni |