views:

150

answers:

2

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 try 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)"

A: 

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.

Andrew Hare
thanks, sound good. I will try it and if it works I'll come and mark your answer
ensecoz
nope, this is not working. when select "None" for Indenting, it means that whenever you enter the newline, you won't get any indenting for that. but when you type <% } %>, it still do auto format.
ensecoz
A: 

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.

Andrew Dunkman