简体   繁体   中英

VS2015 Formatting code on save

I spent 30 minutes trying to make a GIF capture of this small enough to embed in the question but I couldn't get below 3MB and it became unintelligible, so the full capture is here .

I have a large ASPX file. When I click Edit > Advanced > Format document it gives me this section:

    </asp:HyperLink></h3>
<asp:UpdatePanel 

And when I save the document, it reformats to this:

    </asp:HyperLink></h3><asp:UpdatePanel ...

Honestly both annoy me, but unless I explicitly format I don't get the former. However sometimes when I save, it formats to the latter. This is just one example, it mangles the file in many places. Like going from this:

                        </td>
                    </tr>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
<asp:UpdatePanel ...

To this:

</asp:HyperLink></td></tr></table></div></ContentTemplate></asp:UpdatePanel></div><asp:UpdatePanel ...ny places.

I have ReSharper installed, but I have suspended it for this test to rule it out.

So the question is 2 parts:

  1. Why does VS format in 2 different ways, depending on whether it's trigger by a request to format or a save, and
  2. How do I disable this format on save? I can only find options for VSCode, this is VS 2015 Community.

Check the other Visual Studio Extensions that you have installed. There might be one (or perhaps even several) which performs custom code formatting on a file save operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM