Indentation formatting issue in MonoDevelop-Unity 4.0.1 (Win7)

Hi all,

I’m having an issue with MonoDevelop that came with Unity 4.3.2f1 on Windows 7 where the conditional and iterative blocks I write get “corrected” with excessive indentation and badly-aligned closing braces, like so:


I’ve tried looking into the C# formatting options, but couldn’t tweak or find anything that would solve this issue. Google search turned up nothing either. Anyone able to help?


This was driving me nuts! But I found a fix – in MonoDevelop go to Tools → Options → Text Editor → Behavior and switch Indentation Mode from Smart to Automatic. Not so smart after all, huh? Kudos to BoNaNa from Unity forums who solved it.

First let me say I had a lot of trouble with this. I find the Policy setup very confusing in MonoDevelop. I had a similar issue but found in the end that I was formatting my document based on the wrong policy. I’ll try to explain why it wasn’t working, but that might not be the issue here.

Essentially, there are Personal Preference formatting options, Solution formatting options, and Project formatting options. Project options can inherit from the Solution options. I think it uses Personal formatting options as defaults when you create a project, but I’m not sure. When I had issues with formatting, it was because I had Project specific formatting stomping on the Solution’s options.

To set Solution formatting, go to Project → Solution Options → Source Code / Formatting. There you can set the format for each filetype to a standard policy or one that you’ve imported.
To set Project formatting, make sure you have your project loaded and then go to Project → Options → Source code / Formatting. Same deal with setting the policies here, it’s just that it applies to the Solution. You can also set the policy to Inherited to get the settings from the Solution.

After you’ve adjusted the options, Formatting the document should apply those to the code.

Hope that’s helpful, even if it’s not the answer you were looking for.

Note: I think Project → “Apply Policy” adjusts the options for the Project only. I’m probably not going to touch that feature in the future.

MonoDevelop 4.0.12 on Ubuntu 14.04
I found this issue as well and put a video of it up here: