问题描述
在Visual Studio中设计MVC视图(在.aspx或.ascx文件中)我经常使用if语句。当我自动格式化(Ctrl-K,D)的时候,VS用这个丑陋难懂的方式来包装大括号: <%if(Model.UserIsAuthenticated)
{%>
(有些HTML会在这里...)
<%}%>
有没有什么办法让Visual Studio自动格式变成这样:
<%if(Model.UserIsAuthenticated){%>
(有些HTML会在这里...)
<%}%>
还有更好的方法吗?我不想使用剃刀,但它看起来会解决我的问题。我使用VS2010与Resharper 5,如果有帮助。
在工具 - >选项 - >文本编辑器 C# - >格式 - >新行是每个案例(新方法,控制块等)上的开放大括号的规则,也许你可以在那里找到你想要的那个。
In Visual Studio while designing MVC views (in .aspx or .ascx files) I often use if statements. When I auto-format (Ctrl-K,D), VS wraps the braces in this really ugly and hard to read way:
<% if (Model.UserIsAuthenticated)
{ %>
(some HTML goes here...)
<% } %>
Is there any way to make Visual Studio auto-format like this instead:
<% if (Model.UserIsAuthenticated) { %>
(some HTML goes here...)
<% } %>
Or is there a better way to do this? I don't want to use Razor quite yet, but it looks like it would solve my problem. I'm using VS2010 with Resharper 5, if that helps.
Under "Tools->Options->Text Editor->C#->Formatting->New Lines" are the rules for the open brace on each case (new methods, control blocks, etc), maybe you can find the one you want there.
这篇关于我可以使Visual Studio将花括号放在与if语句(HTML中)相同的行上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!