简体   繁体   中英

Visual Studio/ReSharper: How to wrap long lines with commas before params?

I've been customizing my formatting desires using ReSharper for code clean-up. So far I've been able to make the clean-up rules match my coding style within:
ReSharper -> Options -> Languages -> C# -> Formatting Style

One thing I haven't figured out how to do yet is how to have params/fields/list items wrap with leading commas instead of trailing commas.

Example of what I want:

var list = new List<string> {
    "apple"
    , "banana"
    , "orange"
};

Example of what I get currently:

var list = new List<string> {
    "apple",
    "banana",
    "orange"
};

(Not an answer, but this doesn't fit in a comment.)

The reason why some people prefer leading commas to trailing commas is because then it's not the last line that is slightly different from all the others, but the first one. This makes it neater to add new elements at the end.

However, C# allows you to place a comma even after the last element, so all lines look the same:

var list = new List<string> {
    "apple",
    "banana",
    "orange",
};

I asked JetBrains the same question. And they said that it is not possible in ReSharper 5 or 6.

I think I will just need to change my style a little bit then.

If you want the new ReSharper to have that capability, you can try this .

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