How to make R# stop indenting in this case?

I have been through all of the formatting options and just cannot find what is causing this. So many options..

I am using the "Auto-insert closing brace + On Enter after an opening brace" feature.

Given this code, where the * is my cursor:

_uiDispatcher.BeginInvoke(() =>     {*



If I hit Enter I get this:

_uiDispatcher.BeginInvoke(() =>                           {                             *                           }



But I never want that to indent out to the opening paren. I want this instead:

_uiDispatcher.BeginInvoke(() =>     {         *     }



What options do I need to set to make it work this way?
4 comments
Comment actions Permalink

Same here. I kept selecting BSD style and kept wondering why I was getting a
weird Whitesmith or GNU indent. It's not readily obvious and it took me a
while to figure it out as well, but if you go to the Other tab (e.g. C# /
Formatting Style / Other) and scroll to the bottom you'll see an option to
"Indent anonymous method body". Uncheck that and the block should align left
properly. There's also an option to indent initializer blocks just below
this one you may want to turn off.

No idea why the indent styles are in the other tab because if they're set
the braces layout options seem to be mostly moot. It would be more intuitive
if the braces layout options had another item, something like "At next line
flush right (JetBrains style)." ;)

It's even more fun when the indent option is selected and Visual Studio /
ReSharper fight over which layout to use (e.g. ReSharper lets Visual Studio
handle the formatting in some cases).


"Scott Bilas"  wrote in message
news:10204636.16741320719505131.JavaMail.devnet@confluence.jetbrains.net...

I have been through all of the formatting options and just cannot find what
is causing this. So many options..

I am using the "Auto-insert closing brace + On Enter after an opening brace"
feature.

Given this code, where the * is my cursor:

    {*

]]>


If I hit Enter I get this:

                          {
                            *
                          }]]>


But I never want that to indent out to the opening paren. I want this
instead:

    {
        *
    }]]>


What options do I need to set to make it work this way?

---
Original message URL: http://devnet.jetbrains.net/message/5388537#5388537

0
Comment actions Permalink

That almost works. Turning off the option does this:

_uiDispatcher.BeginInvoke(() => {     * }



Whereas I do in fact want it indented..

_uiDispatcher.BeginInvoke(() =>     {         *     }



I just don't want it all the way over to the parens.

Still, your suggestion is an improvement, so thanks! Much easier to go back and indent a single level than to un-indent potentially 40+ columns.
0
Comment actions Permalink

I think what you want in this case is to go into Code Editing / C#/
Formatting Style / Braces Layout and change Anonymous method declaration
from At next line (BSD style) to At next line indented 2 (GNU style). There
are a variety of styles you can use for the braces layout:

Whitesmiths:
_uiDispatcher.BeginInvoke(() =>
    {
    *
    });

At end of line:

_uiDispatcher.BeginInvoke(() =>{
    *
});

BSD style:

_uiDispatcher.BeginInvoke(() =>
{
    *
});

K&R style:

_uiDispatcher.BeginInvoke(() => {
    *
});

GNU style:

_uiDispatcher.BeginInvoke(() =>
    {
        *
    });

"Scott Bilas"  wrote in message
news:18769811.29941320784584428.JavaMail.devnet@confluence.jetbrains.net...

That almost works. Turning off the option does this:

{
    *
}]]>


Whereas I do in fact want it indented..

    {
        *
    }]]>


I just don't want it all the way over to the parens.

Still, your suggestion is an improvement, so thanks! Much easier to go back
and indent a single level than to un-indent potentially 40+ columns.

---
Original message URL: http://devnet.jetbrains.net/message/5390830#5390830

0
Comment actions Permalink

B-)

So many ways to configure formatting, so confusing to me. Thanks very much, that's what I needed!

0

Please sign in to leave a comment.