我可以使Visual Studio将花括号放在与if语句(HTML中)相同的行上吗? [英] Can I make Visual Studio place curly braces on the same line as an if statement (in HTML)?

查看:203
本文介绍了我可以使Visual Studio将花括号放在与if语句(HTML中)相同的行上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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中)相同的行上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆