8

I'm using VS 2010 + resharper, and i'm tired reformatting bracket indentation in code as i want it. As example if i have code like:

operators.Keys
    .ToList()
    .ForEach(k => filters
        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
            .Select(t => new QueryFilter()
            {
                Operation = operators[k],
                PropertyName = t.Item1,
                Value = t.Item2
            })))

And if i put ; in the end VS (or resharper) 'fixes' bracket indentation so code becomes like:

operators.Keys
    .ToList()
    .ForEach(k => filters
                        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
                                    .Select(t => new QueryFilter()
                                    {
                                        Operation = operators[k],
                                        PropertyName = t.Item1,
                                        Value = t.Item2
                                    })));

Same happens if i use resharper's code cleanup. I probably could turn off automatic code reformatting on ; but i need it in other situations. I tried changing code formating options both in VS and resharper setting but never got indentation as i want it.

How could i configure vs or resharper so that it would not do more than one tab formating? Or maybe there is other plugin i can use (together with r#) specificly for this purpose?

EDIT: for anyone interested in this problem here is same question in r# forum http://devnet.jetbrains.net/thread/304794 anyone who would like to see better nested code indentation from r# are welcome to vote for it here http://youtrack.jetbrains.net/issue/RSRP-88220

Andrej Slivko
  • 1,236
  • 2
  • 12
  • 27
  • 1
    Stop writing heavily nested code? Introduce smaller well named methods, explaining variables, and clearer return values. – Ritch Melton Jun 03 '11 at 07:37
  • @Ritch Melton i like it that way, i usually get less bugs if i write it in such way. This code snippet is from my current feature that i'm working on now, it didn't went through refactoring phase so please don't judge it. – Andrej Slivko Jun 03 '11 at 07:43
  • 3
    I tend to like code like this as well. This isn't the best example, but generally linked method calls LINQ style is more expressive and readable. At least to me. I guess it's a matter of taste and coding style. – Øyvind Bråthen Jun 03 '11 at 07:51
  • At any rate he didn't ask for how to write code, he asked how to configure resharper – havardhu Jul 26 '13 at 11:58
  • if you are a paying customer of resharper, have you try seek solution from them? – Kelmen Jul 27 '13 at 07:00

1 Answers1

1

just guessing...

go to ReSharper -> options -> Code Editing -> c# -> Formatting Style -> Other

Search in Align Multiline Constructs and try toggling the state of checkbox "Chained method calls" (I suppose your value is 'checked' for this checkbox).

if not this one, i expect that required setting is somewhere very near :-)

Marzena
  • 363
  • 4
  • 14