Forum Visual Studio

Indentation of Anonymous Methods

I can't seem to figure out a way to make Xamarin Studio "properly" indent anonymous methods. I've tried every indentation and braces option available, but none achieve the result I'm looking for. I can't even get it to not format my anonymous methods at all, which would be preferable to the behavior I'm getting now.

Here is an example of what I'd like:

UIView.Animate(
    0.3,
    () =>
    {
        // Code block.
    });

Here is what I get:

UIView.Animate(
    0.3,
    () =>
    {
    // Code block.
});

The worst part is, every time I terminate a line within code block, it de-dents that line. Does anyone have any idea how I can achieve the formatting I'd like? If not, is there any way to just turn it off?

Thanks in advance,
Chad

Posts

  • mhutchmhutch USMember, Xamarin Team Xamurai

    There are two things at play here, the smart indenter and the code formatter. The smart indenter is what calculates the indent for new lines, and the code formatter is what reformats each statement on the final semicolon, etc.

    The code formatter style is configurable via in the code style policies. If you can't find an option for your style, please file a bug. The indenter unfortunately does not respect style options that this time.

    You can turn them both off in preferences - change indenter to "auto" (i.e. copy previous line's indent) and disable the on-the-fly formatter.

Sign In or Register to comment.