Visual Studio 2005/2012: How to keep the first curly figure on one line?

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

body { color:#222; } 

instead of this:

 body { color:#222; } 

when I automatically format the code.

+82
visual studio
Sep 02 '08 at 13:52
source share
7 answers

FROM#

  • From the Tools menu, select Options
  • Click Show all settings (checkbox at bottom left) (Show all settings in VS 2010)
  • Text editor
  • FROM#
  • Formatting
  • New lines

And check if you want new lines with brackets

Css:

almost the same but fewer options

  • From the Tools menu, select Options
  • Click Show all settings (checkbox at bottom left) (Show all settings in VS 2010)
  • Text editor
  • CSS
  • Format

And how do you choose the desired formatting (in your case, the second switch)

For Visual Studio 2015:

Tools → Options

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

and uncheck each box under "New line options for curly braces"

enter image description here

+144
Sep 02 '08 at 13:55
source share

Tools → Options → Text Editor → C # → Formatting → New Lines → New Line Options for curly brackets → Uncheck all the boxes.

+21
02 Sep '08 at 13:55
source share

The official MS guidelines (at the time in 2008) indicate the presence of a curly brace on the same line as the method / property / class, and many other things that are not used in Visual Studio.

You can change all of these auto-text options:
Tools → Options → Text Editor → [Language you want to change]

UPDATE: This was based on the book “Framework Design Guides” written by some of the core people from the .NET team. If you look at the source code for the likes of ASP.NET MVC , it will not be more accurate .

+9
Sep 02 '08 at 14:01
source share

Go to Tools -> Options -> Text Editor -> CSS -> Formatting . Click on "Semi-Advanced" that matches the style you specify.

Options screen

+6
Jul 09 '13 at 20:39
source share

For CSS, you will need the "Semi-finished" option.

+4
Sep 02 '08 at 13:57
source share

In VS 2008/2010, there is a special formatting option to keep the open figure on the same line:

Click Tools> Options
Select "CSS" in the tree "Text Editor" node
Select "Formatting" in the "CSS" section of the node
Click Semi-Advanced 'Switch

You will see a preview of what the various radio buttons will use to format

+2
Dec 12 2018-10-12T00:
source share

If you are looking for this option in Visual Studio 2014 , then it is under the advanced one and is now in the “Bracket Position” drop-down list:

enter image description here

0
Dec 10 '14 at 11:00
source share



All Articles