Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 482
Kredns Avatar asked Jun 21 '09 02:06

Kredns


People also ask

How do I stop Visual Studio from auto formatting?

The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.


2 Answers

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

like image 98
xian Avatar answered Sep 19 '22 03:09

xian


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)

like image 30
GrendleM Avatar answered Sep 19 '22 03:09

GrendleM