简体   繁体   中英

VS2010: How to set format on enter

I've downloaded the Productivity Power Tools plug-in for VS2010. I'm using the setting to auto insert the closing brace. However, I can't seem to get the editor to format correctly on enter press. Probably best to show what I'm asking with a code snippet:

// I will be using the pipe | to show the carret

// At this point, the closing brace is inserted:
var foo = new Foo{|
// So it becomes this:
var foo = new Foo{|}

// Now pressing enter formats it like this:
var foo = new Foo{
    |
}

// BUT THIS IS HOW I WANT THE FORMATTING TO BE:
var foo = new Foo
{
    |
}

// It is however formatted correctly on semilcolon:
// So this:
var foo = new Foo{
    var bar = 5;|
}
// Becomes this:
var foo = new Foo
{
    var bar = 5;
};|

There is an option called "Auto Brace Completion"
You can get it via Tools-> Options -> Productivity Power Tools -> All Extensions
You can turn it OFF if you don't like the default behaviour, and user VS2010 settings

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