Valtinho
Valtinho

Reputation: 327

How to prevent Visual Studio 2013 from autocompleting HTML comments incorrectly

I have Visual Studio Professional 2013 and every time I want to comment out an HTML tag, VS automatically adds a beginning comment at the end of the tag. This is a very annoying behavior. Does anyone know how to fix this?

Example:

My original html is:

<a href="http://google.com">Click to go to google</a>

Then I start to comment out the line by adding !-- after the first <

<!--a href="http://google.com">Click to go to google</a>

And VS automatically autocompletes with another !-- like this:

<!--a href="http://google.com">Click to go to google</!--a>

Which I then have to manually fix to:

<!--a href="http://google.com">Click to go to google</a-->

Upvotes: 1

Views: 31

Answers (2)

Adam Buchanan Smith
Adam Buchanan Smith

Reputation: 9449

It is because Visual Studios thinks that the !-- is part of the <tag>, so its duplicating it on the closing <tag>.

To fix comment like this instead: <!--<a></a>-->

Notice how the line comment is outside of the tag.

Upvotes: 1

Rob
Rob

Reputation: 15160

I'm going to take a shot and guess that it's happening because you still have the closing tag for the <a> and you start your comment within that tag instead of outside it: <!-- <a ... which is confusing VS.

Upvotes: 1

Related Questions