Hi,

I've had this problem for a while now, it seems to come and go (sometimes it happens, sometimes it doesn't) and I can't really figure out what's wrong.

Basically my aspx code will sometimes format automatically, except not in the way I want it to. I always structure html and xml-like code as such:
Code:
<parent>
    <child />
    <child>
        <subchild />
        <subchild />
    </child>
</parent>
This way I can quickly see which tags belong to which, and I think this is the usual way html is formatted, right?

Anyway, suppose that I have this code in my aspx code window (don't mind that it's not aspx code, that's not the point), then sometimes VS will automatically format it to this:
Code:
<parent>
    <child />
    <child>
        <subchild />
        <subchild /></child></parent>
Basically it seems to put all closing tags on the last line, leaving me sometimes (with many nested tags) with an extremely long line at the end, making it completely impossible to see the structure of my code.



Here is an actual example. This is how I wrote my code:
xml Code:
  1. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  2.    
  3.     <h2>Login</h2>
  4.  
  5.     <p>
  6.         <asp:Label runat="server" ID="lblMessage" Font-Bold="true" ForeColor="Red" />
  7.     </p>
  8.  
  9.     <p>
  10.         <asp:Table runat="server">
  11.             <asp:TableRow>
  12.                 <asp:TableCell>Gebruikersnaam:</asp:TableCell>
  13.                 <asp:TableCell Width="35px" />
  14.                 <asp:TableCell>
  15.                     <asp:TextBox runat="server" ID="txtUsername" />
  16.                 </asp:TableCell>
  17.             </asp:TableRow>
  18.  
  19.             <asp:TableRow>
  20.                 <asp:TableCell>Wachtwoord:</asp:TableCell>
  21.                 <asp:TableCell Width="35px" />
  22.                 <asp:TableCell>
  23.                     <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" />
  24.                 </asp:TableCell>
  25.             </asp:TableRow>
  26.         </asp:Table>
  27.     </p>
  28.  
  29.     <p>
  30.         <asp:Button runat="server" ID="btnOK" Text="Login" OnClick="btnOK_Click" />
  31.         <asp:Button runat="server" ID="btnCancel" Text="Annuleren" OnClick="btnCancel_Click" />
  32.     </p>
  33.  
  34. </asp:Content>

Now when I change my view to 'Split view' (to see both code and design in one window) and start clicking in the design view, sometimes (not always for some reason), VS seems to think I want to format my code, and it changes it into this mess:
xml Code:
  1. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  2.    
  3.     <h2>Login</h2>
  4.  
  5.     <p>
  6.         <asp:Label runat="server" ID="lblMessage" Font-Bold="true" ForeColor="Red" />
  7.     </p>
  8.  
  9.     <p>
  10.         <asp:Table runat="server">
  11.             <asp:TableRow>
  12.                 <asp:TableCell>Gebruikersnaam:</asp:TableCell>
  13.                 <asp:TableCell Width="35px" />
  14.                 <asp:TableCell>
  15.                     <asp:TextBox runat="server" ID="txtUsername" />
  16.                 </asp:TableCell></asp:TableRow><asp:TableRow>
  17.                 <asp:TableCell>Wachtwoord:</asp:TableCell><asp:TableCell Width="35px" />
  18.                 <asp:TableCell>
  19.                     <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" />
  20.                 </asp:TableCell></asp:TableRow></asp:Table></p><p>
  21.         <asp:Button runat="server" ID="btnOK" Text="Login" OnClick="btnOK_Click" />
  22.         <asp:Button runat="server" ID="btnCancel" Text="Annuleren" OnClick="btnCancel_Click" />
  23.  
  24.     </p>
  25.  
  26. </asp:Content>
This is actually not as bad as it gets, I've seen it way worse, but still I cannot read this mess anymore and I have to go back and manually format the code again until it just happens again...


Using Format Document helps a little bit but it still isn't the way I want it... After Format Document, the Table for example is condensed into this:
xml Code:
  1. <asp:Table runat="server">
  2.             <asp:TableRow>
  3.                 <asp:TableCell>Gebruikersnaam:</asp:TableCell>
  4.                 <asp:TableCell Width="35px" />
  5.                 <asp:TableCell>
  6.                     <asp:TextBox runat="server" ID="txtUsername" />
  7.                 </asp:TableCell></asp:TableRow>
  8.             <asp:TableRow>
  9.                 <asp:TableCell>Wachtwoord:</asp:TableCell><asp:TableCell Width="35px" />
  10.                 <asp:TableCell>
  11.                     <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" />
  12.                 </asp:TableCell></asp:TableRow>
  13.         </asp:Table>
It still places many closing tags on a single line for some reason.



I have made several journeys through the many Text Editor options, but I have not yet been able to fix this issue... I've looked at the HTML options, XML options, whatever seems likely, but I cannot figure out the correct combination of options that will make VS auto-format my code in the usual way, instead of just dropping multiple closing tags on one line...


Any help?