开发者

Is it possible to disable auto formatting only for Html pages (not c#) on VS2010?

开发者 https://www.devze.com 2022-12-27 16:18 出处:网络
During the design html pages or aspx pages, I like to do the pure coding without Html Designer. The problem is that I like to have the following format on html page for better readability.

During the design html pages or aspx pages, I like to do the pure coding without Html Designer. The problem is that I like to have the following format on html page for better readability.

<div>
  <% if (1 == 1) { %>
    Hello
  <% } else { %>
    World
  <% } %>
</div>

As you can guess, whenever you type '}' or ';' or etc, visual studio t开发者_开发技巧ry to do the auto format and change to the following format

<div>
  <% if (1 == 1) 
     { %>
    Hello
  <% }
     else
     { %>
    World
  <% } %>
</div>

The question is "Is it possible to disable auto formatting just only for HTML pages on VS2010? (NOT for C# code, I still like to have auto formatting for C# pages)"


Yes, go to these two spots:

Tools > Options > Text Editor > HTML > Tabs > Indenting

Select the None radio button.

Tools > Options > Text Editor > HTML > Tabs > Miscellaneous

Uncheck Format HTML on paste.


Tools > Options > Text Editor > Jscript > Formatting

Uncheck "Format completed line on Enter" and "Format completed block on }"


I had the same issue, and I found out that it was due to Resharper, not Visual Studio.

To disable html formatting in Resharper, go to: RESHARPER > Options > Code Editing > HTML > Editor

and uncheck "Auto-format on enter" and "Auto-format on closing tag"


Tools > Options > Text Editor > HTML > Formatting > Tag Specific Options...

It's a confusing dialog, but notice the "preview" pane near the bottom to see how each rule is going to be applied.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号