Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

view - Can I make Visual Studio place curly braces on the same line as an if statement (in HTML)?

In Visual Studio while designing MVC views (in .aspx or .ascx files), I often use if statements. When I auto-format (Ctrl+K+D), Visual Studio 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Under ToolsOptionsText EditorC#FormattingNew 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.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...