简体   繁体   中英

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?

AFAIK 没有办法阻止 Visual Studio 这样做。

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)

您购买ReSharper并将其用于所有格式设置,您可以完全按照您想要的方式进行设置 =)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM