配置的&LT格式;%%GT;在Visual Studio编辑器模块 [英] Configuring the formatting of <% %> blocks in Visual Studio editor
问题描述
在Visual Studio 2010中,在工具 - >选项 - >文本编辑器 - > HTML - >格式 - >标记特定选项,也有选项的配置如何编辑自动格式不同的HTML和ASP.NET标签。这包括诸如是否应该自动前后标签,等以后把换行。
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.
有没有配置格式规则℃的地方;%%>&LT;%=%>和&lt;%:以类似的方式%>块
Is there a place to configure the formatting rules for <% %> <%= %> and <%: %> blocks in a similar fashion?
在我特别想和以前没有下强制换行;%=和&lt;%:块。
In particular, I would like to not force a newline before <%= and <%: blocks.
例如,我已经配置的选项为h1标签不围绕其内容添加换行,并与静态内容的伟大工程,但是当有一个和下它不工作;%:或LT;%=阻止h1标签。我目前得到这样的:
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>
但我想这样的:
<h1><%: Model.Name %></h1>
在一个完美的世界,我也想为自动格式&LT内容;%%>块,以确保总有℃之间的空间;%及其内容
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.
例如,良好的:
<% if (something) { %>
坏的:
<%if (something) {%>
那么,还有什么地方埋葬,以控制这两种格式的行为的任何设置?
So, are there any settings buried somewhere to control either of these formatting behaviors?
推荐答案
感谢@schellack在正确的方向knudging我。这里有我需要得到我想要的(内的所有标签的特定选项对话框)行为的设置:
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):
- 默认设置 - >客户端标签支持内容
- 换行符:之前和之后
- (这使得H1,P,以及类似的标记表现我想要的方式。其他人可能需要无作为一种选择。个人preference我想。)
- 标签名称:%
- 关闭标签:无结束标记
- 换行符:之前和之后
- (这捕获实际code块和前行的休息时间和code块后,让他们从HTML标记分离。)
- 标签名称:%:
- 关闭标签:无结束标记
- 换行符:无
- (这捕获&LT;%:%>块和HTML标记没有换行让他们在线)
- 标签名称:%=
- 关闭标签:无结束标记
- 换行符:无
- (以previous种相似这捕获&LT;%=%>块和HTML标记没有换行让他们在线)
诀窍是,编辑似乎认识到&LT;%%>块为名为%客户标记,没有结束标签。同样成交为&LT;%:%>和&lt;%=%>
The trick is that the editor seems to recognize <% %> blocks as a client tag named '%' that has no closing tag. Same deal for <%: %> and <%= %>.
使用这些设置(在Visual Studio中的默认设置的其余部分相结合)我得到格式化的标记,看起来像以下(这是紧凑的外形我一直在寻找):
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):
<h1><%: Model.Name %></h1> <ul> <% foreach (var item in Model.Items) { %> <li><%: item %></li> <% } %> </ul>
作为又,它不会出现我的问题的第二部分是可能的。
As yet, it doesn't appear that the second part of my question is possible.
这篇关于配置的&LT格式;%%GT;在Visual Studio编辑器模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!