A Note about using MonoDevelop and Custom Formatting.

I ran into an issue with MonoDevelop that was extremely annoying. I upgraded to the latest unity build this morning and it came bundled with a new version of MonoDevelop (4.0.1). There seems to be some nice changes in here but one of the first things I noticed was that my code was not being formatted correctly. My first attempt was to configure C# formatting via the preferences pane… I spent sometime making things look right hit ok and …. nothing. Worst of all, I restarted MonoDevelop and found that all my settings had been reset. After trial, error, research and heart palpitations here is what I found.

MonoDevelop y u no save settings

MonoDevelop y u no save settings

I did some research and found that those settings are only for new solutions, and any existing solution had to be customized individually via Project->Solution Options. I did that, and things started getting better. I was able to modify the indentation and spacing settings and upon hitting save it no longer looked like a grenade went off in my CS file. Shortly afterwards I did a Synch MonoDevelop project within Unity….. ALL MY SETTING GOT RESET again! Now, I had foreseen something like this happening so I saved off a few files (sln, userprefs, etc..). Needless to say I was unable to restore my settings no matter what I did. In the end I found the true solution to this issue.

Below you’ll find steps that will help you save your custom code formatting settings for C# in MonoDevelop, even if they are reset by unity after doing a synch you’ll be able to quickly restore them.

1. MonoDevelop->Custom Policies

2. Add Policy (Button on top right)

3. Setup formatting the way you like.

4. Export it to a file. (I’m keeping mine in source control so I can restore it on different machines)

5. With the solution open, goto: Project->Apply Policy. Note: You can import from a file, but you’ll likely have your new policy available via drop-down if you are on the same machine it was created with.

6. Relief. Your settings are restored. No more code grenades.

Hope this helps!

Share Button


  1. George says:

    It helped A LOT!
    Thank you VERY much!

  2. John Tuttle says:

    Thank you thank you thank you thank you!

Speak Your Mind