Is it possible to change the way Resharper 4.5 formats code in aspx/ascx files?

╄→гoц情女王★ 提交于 2019-12-11 11:23:36

问题


I find myself constantly pressing ctrl-z to undo the automatic formatting that happens in templates. For example Resharper would like to format a foreach loop like this:

<%
  foreach (var product in Model.Items)
  { %>
      <li><%= product.Name %></li>
<% } %>

This is fine in c# code files but it just seems messy in templates. I would prefer to format it like this

<% foreach (var product in Model.Items) { %>
    <li><%= product.Name %></li>
<% } %>

回答1:


Open Visual Studio Goto Resharper > Options... > Langauges > C# > Formatting Style > Braces Layout > Other

Change to "At end of line (no space)"

Note this will affect your C# as well.

It is a bit annoying that you cant specify a different code sytle for you aspx pages since its often you do want something differnt.




回答2:


Resharper does not allow you to create custom formatting. You can only change the predefined formatting under options. I poked around and did not see <% %> formatting options. Sorry :(




回答3:


Starting from ReSharper 7.1 (currently at EAP), there is an option to use K&R style in ASP and Razor while continuing to use BSD for C#. ReSharper | Options -> Code Editing | ASP.NET | Editor & Formatting -> Override brace style for C# to always use "At end of line (K&R style)"



来源:https://stackoverflow.com/questions/853671/is-it-possible-to-change-the-way-resharper-4-5-formats-code-in-aspx-ascx-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!