none
How to stop the HTML editor from auto-matching HTML tags?

    Question

  • This topic is probably in the wrong place, but I couldn't find where else to post it.

    Please consider this snippet of HTML: 

    <a class=article-author href=#>
      <img src="http://placekitten.com/100/100" width=80 height=80 alt="">
      <strong>Author's Name</strong>
      <span class=phone href="tel:+31123456789">012 3456 789</a>
      <span class=mobile href="tel:+31123456789">012 3456 789</a>
      <span class=email href="mailto:kittens@example.com">kittens@example.com</a>
    </a>

    I KNOW that this is not correct, this snippet is in a state of right in the middle of being updated. I was trying to change the three spans from <a> tags into <span> tags. Now, the closing tag matches up with the very first <a> tag, which is probably alright, because the code is not correct yet.

    But annoyingly, when I type over the first </a>,  VS2012 also updates the very first <a>. But when I change the first one back, it updates the other way around. AARGH. So in this situation, there is simply no way to change the </a> into a </span> without the first <a> being touched.

    How do I disable this highly annoying feature? Or more generally, how do I tell VS2012 to NOT TOUCH MY CODE. Sorry for the rant, but this is rediculous, I hate intelligence that doesn't work.

    Friday, March 8, 2013 11:01 AM

All replies

  • Hi thany1,

    Thank you for posting in the MSDN forum.

    We could change the Text Editor settings under TOOLS->Options->Text Editor->HTML under VS IDE.

    For example, if we want to disable “Auto insert close tag”, you could set it under TOOLS->Options->Text Editor->HTML->Formatting. Hope it could help.

    If I have misunderstood anything, please make free feel to let me know.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 11, 2013 3:23 AM
    Moderator
  • Unfortunately, Jack's answer doesn't help at all.  I don't think people realize that "Auto Insert Close Tag" and "Automatically change an existing tag because you think it's my close tag, but it's not because I'm not done ADDING NEW CODE YET" is not the same thing.  Here is the example again in a simpler form.  I have named the tags with ID's simply for reference purposes but they don't need to be named at all to reproduce this.

    Start with the following code block (or anything similar):

    <div id="div1">
      Hello World
    </div>

    Now start to insert a CHILD tag inside of the first tag like so:

    <div id="div1">
       <DIV id="span1">
       Hello World
    </div>

    While writing the inner DIV tag, I realized it should have been a SPAN instead of a DIV.  So I go back and correct it after the ">" was already added to the element "span1".  Suddenly, Visual Studio in it's COMPLETELY INCORRECT infinite wisdom, decides that the closing DIV tag goes with the inner DIV labeled "span1".  So when go back and change the DIV tag to be a span, VS changes the closing tag to match it.

    <div id="div1">
       <span id="span1">
       Hello World
    </SPAN>

    That is NOT CORRECT at all and screws up my code ALL THE TIME.  I don't know a single developer that writes continuous code from start to finish and NEVER goes back to edit or insert elements inside of other elements.  What's worse is that when I go back to correct the erroneous closing SPAN tag (that I was lucky enough to notice), VS decides to be "helpful" and changes the opening SPAN to be a DIV now...?????  So I'm back where I started when I tried to correct the "span1" tag to begin with!

    <div id="div1">
       <DIV id="span1">
       Hello World
    </div>

    If VS is intent on being helpful, it needs to have a way for me to say "NO THANKS" to guessing what I'm writing WHILE I'M WRITING IT!  If you want to go back and "review" my code later and let me know what you think was missed if I ask you to, then that's fine.  But I want to you to get out of my code and let me type whatever I want to type in the IDE.  If I wanted you to change stuff for me, I'd go back to some WYSIWYG editor and play dumb from the get-go.

    As you may be able to tell, I'm extremely frustrated that I spend $500 or whatever is was on this product only to find out that it screws up code and introduces bugs into code that I didn't write.  If there's not a way to turn it off or disable whatever that feature is called, I'd be better off going to some other editor that lets me type what I want without extra "help".

    This was introduced in VS 2012.  VS 2010 did not behave this way.
    • Edited by Angry_Coder Thursday, November 21, 2013 2:39 AM Added VS 2010 info and bold
    Thursday, November 21, 2013 2:30 AM
  • Here's a link to someone else who posted this behavior to YouTube:

    http://www.youtube.com/watch?v=0oXCly-gMwg

    (Apparently I can't post links yet)

    Thursday, November 21, 2013 2:44 AM
  • I can also confirm that this still happens on VS 2013.  I just installed the trial and it does the exact same thing.  There as GOT to be a way to turn this stupid thing off?!?!?!
    Friday, November 22, 2013 1:55 AM
  • Why did you mark this as the answer? IT'S WRONG AND IT DOESN'T WORK! You obviously didn't even try to reproduce what he's describing because if you had, you wouldn't have posted this lame useless answer, much less set it as accepted.

    This site sucks.

    Wednesday, July 16, 2014 8:48 PM
  • I suggest also disabling the setting for the XML language as well (why is HTML not nested under this?).

    In VS 2014, it's under Options > Text Editor > XML > Miscellaneous > Close tags

    However, I can't seem to figure out how to configure the same for my *.config files (also a type of XML which isn't configured by the XML settings!!!). I really hate autocomplete, and especially when it is automatically enabled!

    Tuesday, October 3, 2017 3:34 PM