Visual Studio 2005/2012: How to keep first curly b

2019-01-13 06:59发布

Trying to get my css / C# functions to look like this:

body {
    color:#222;
}

instead of this:

body 
{
    color:#222;
}

when I auto-format the code.

7条回答
我想做一个坏孩纸
2楼-- · 2019-01-13 07:35

C#

  1. In the Tools Menu click Options
  2. Click Show all Parameters (checkbox at the bottom left) (Show all settings in VS 2010)
  3. Text Editor
  4. C#
  5. Formatting
  6. New lines

And there check when you want new lines with brackets

Css:

almost the same, but fewer options

  1. In the Tools Menu click Options
  2. Click Show all Parameters (checkbox at the bottom left) (Show all settings in VS 2010)
  3. Text Editor
  4. CSS
  5. Format

And than you select the formatting you want (in your case second radio button)

For Visual Studio 2015:

Tools → Options

In the sidebar, go to Text Editor → C# → Formatting → New Lines

and uncheck every checkbox in the section "New line options for braces"

enter image description here

查看更多
登录 后发表回答