Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio/ReSharper code formatting - C#

When creating a new type using the object initialiser syntax, Visual Studio automatically moves the braces to align with the type after the new keyword.

Like this

MyType myType = new MyType
                    {

                    };

However, I would prefer it not to do this and instead leave it like so

MyType myType = new MyType
{

};

Any ideas how to do this - I've been through all the Visual Studio formatting options and can't find one that is appropriate

Any ideas?

like image 803
ChrisCa Avatar asked Feb 10 '12 09:02

ChrisCa


1 Answers

From my most popular answer here:

  1. In Braces Layout, set Array and object initializer to At Next line (BSD Style).
  2. In Other, make sure that Continuous line indent multiplier is set to 1.
  3. In Other, make sure that Indent array, object and collection initializer block is unchecked.

You will have the style that you want!

like image 140
Igal Tabachnik Avatar answered Oct 14 '22 21:10

Igal Tabachnik