In Visual Studio 2010, under Tools -> Options -> Text Editor -> HTML -> Formatting -> Tag Specific Options, there are options for configuring how the editor auto formats different HTML and ASP.NET tags. This includes things like if it should automatically put a newline before and after the tag, etc.
Is there a place to configure the formatting rules for <% %> <%= %> and <%: %> blocks in a similar fashion?
In particular, I would like to not force a newline before <%= and <%: blocks.
For example, I have already configured the options for the h1 tag to not add newlines around its contents and that works great with static content, but it doesn’t work when there is a <%: or <%= block in the h1 tag. I currently get this:
<h1>
<%: Model.Name %></h1>
but I would like this:
<h1><%: Model.Name %></h1>
In a perfect world, I would also like to auto format the contents of <% %> blocks to make sure there is always a space between the <% and its contents.
For example, good:
<% if (something) { %>
bad:
<%if (something) {%>
So, are there any settings buried somewhere to control either of these formatting behaviors?
Thanks to @schellack for the knudging me in the right direction. Here are the settings I needed to get the behavior I wanted (all within the tag specific options dialog box):
The trick is that the editor seems to recognize <% %> blocks as a client tag named ‘%’ that has no closing tag. Same deal for <%: %> and <%= %>.
With these settings (combined with the rest of the defaults in Visual Studio) I get formatted markup that looks like the following (which is the compact form I was looking for):
As yet, it doesn’t appear that the second part of my question is possible.