views:

379

answers:

4

This seems like it should be really simple to do but I just can't figure it out. I want to allow Visual Studio to keep auto formatting my code as it is, except for this part:

public SomeClass : BaseClass {
    public SomeClass() 
        : base()
    {

    }
}

Why can't I have it look like this instead:

public SomeClass : BaseClass {
    public SomeClass() : base() {

    }
}

I looked through Tools -> Options -> Text Editor -> C# -> New Lines and can't find it. Is there a way I can change it to allow auto formatting and my second example?

+1  A: 

i don't know, but have concluded that it is a waste of time/effort to fight the defaults; save your energy for the battles that matter ;-)

Steven A. Lowe
Just wondering, do you use the ALL the default settings that come with VS?
Lucas McCoy
It is critical that every person (and every computer they use) format code the same way. So, I pick the default formatting style, so it's consistent right out of the box. (Luckily I had a say in the defaults...)
Jay Bazuzi
@[Lucas Aardvark]: yes - at least i don't remember changing any of them significantly. Maybe I'm just lazy! ;-)
Steven A. Lowe
@Steven A. Lowe: Nothing wrong with being lazy. I'm just a little OCD about my IDE.
Lucas McCoy
A: 

AFAIK there is no way to prevent Visual Studio from doing this.

kitchen
+1  A: 

Are you sure that unchecking:

Options -> Text Editor -> C# -> Formatting -> New Lines -> Place Open Brace on new line for types

doesn't do what you want?

and also uncheck

Place open brace on newline for methods.

(nvrmind.. I see what you are getting at... It is annoying)

GrendleM
Welcome to Microsoft!
Lucas McCoy
A: 

You purchase ReSharper and use that for all of your formatting, you can set it up exactly how you want it =)

Jon Erickson