Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange indentation upon code formatting with MonoDevelop (double indentation)

When I use code formatting with MonoDevelop (Shortcut: Ctrl+I), everything gets double-indented:

namespace Example
{ 
        public class Test
        {
                public static void Main(string[] args)
                {
                        for (int i = 0; i < 10; i++)
                        {
                                Console.WriteLine("{0}: Test", i);
                        }

                    //this would be the desired indentation width!
                        //Not this!
                }
        }
}

Checking with the preferences under Source Code -> Code Formatting -> C# source code under Text Style, Tab width and Indent width are set to 4. Nevertheless, I get an indent width of 8 instead of 4, so twice as much indentation.

I'm working on a team-project with Unity3D and using MonoDevelop-Unity version 4.0.1.

like image 307
Mobiletainment Avatar asked Dec 01 '13 20:12

Mobiletainment


1 Answers

It turned out that the solution/project itself had a different code formatting applied and it was overriding my settings from the preferences.

To adjust the solution/project specific settings, right click on the Solution/Project and choose Options. Under Source Code->Code Formatting->C# source are the actual tab width and indent width settings for this solution/project that are applied upon code formatting.

like image 154
Mobiletainment Avatar answered Sep 17 '22 21:09

Mobiletainment