Robin Winslow
Robin Winslow

Reputation: 11502

Don't indent for asp sections in HTML files

In Visual Studio 2010, is it possible to change the formatting of HTML documents such that it doesn't indent for <asp:*> sections? I'm trying to achieve this:

<asp:content contentplaceholderid="content" runat="server">
<!DOCTYPE html>
<html>
    <head>
    ...
    </body>
</html>
</asp:content>

Rather than this:

<asp:content contentplaceholderid="content" runat="server">
    <!DOCTYPE html>
    <html>
        <head>..</head>
        <body>..</body>
    </html>
</asp:content>

So that what eventually gets served to the browser has nothing before the <!DOCTYPE html>:

<!DOCTYPE html>
<html>
    <head>..</head>
    <body>..</body>
</html>

Which is just neater, and I think probably less error-prone.

I know I could just manually format the document and then never use the auto-format option (ctrl+k ctrl+d), but that's just annoying.

Upvotes: 1

Views: 396

Answers (1)

immutabl
immutabl

Reputation: 6903

For specific ASP tags

Tools -> Options -> Text Editor -> HTML -> Formatting -> then hit the button marked 'Tag Specific options' on the right pane -> then chose ASP.Net Controls on the left pane. Then choose the tag you wish to modify (asp:placeholder) and uncheck the checkbox marked 'Indent contents'.

For all server tags

In the "Tag specific options" windows, under "Default Settings" select "Server tag supports contents" and uncheck "Indent contents".

Upvotes: 1

Related Questions