Search code examples
c#visual-studiovisual-studio-2008preferences

How to stop Visual Studio from auto formatting certain parts of code?


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?


Solution

  • 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)