Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Visual Studio not put { on a new line?

If I have code like this

if(true){ 

and I add

} 

it is transformed into

if (true) { } 

but I would like it to stay in format

if (true) { } 

Even if I copy code that has if like this, it is transformed into the longer version.

P.S. I understand that it's a C++ and C# standard to use the longer version, however I do come from a different standard, and it's easier for me to use the shorter version.

I bet there is some formatter option that can be turned off or changed.

like image 894
IAdapter Avatar asked Feb 01 '11 09:02

IAdapter


People also ask

How to change Visual Studio brackets?

"Tools" menu → Options → Environment → Fonts and Colors → Select "Brace Matching or Brace Matching(Rectangle)" under "Display items" → select a "Background Color" → OK → Finish. 2.

How do I format Visual Studio?

In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F. To format a range, in an already opened project, open the document that you want to modify, select the specific range to format, right-click, and select Format Selection.


1 Answers

Go to Tools -> Options -> Text Editor -> C# -> Code Style -> Formatting-> New Lines

Here there are a lot of options. Remove the check on all options here to never put the open bracket on a new line.

EDIT

The section New Line Options for expressions does not relate to placement of code in conjunction with brackets, so those you don't need to touch.

like image 130
Øyvind Bråthen Avatar answered Oct 06 '22 05:10

Øyvind Bråthen