Basic If Block Formatting

2 posts, 0 answers
  1. Patrick Barranis
    Patrick Barranis avatar
    68 posts
    Member since:
    Jul 2009

    Posted 23 Jun 2013 Link to this post


    I would like my if or if-else blocks, if they are single-line, to be formatted without curly brackets.  I see many settings that seem to imply they would do this, but I cannot get them to produce the right result.  Can you please point me to the exact settings I would need to set to get this to happen.

    I would like it to format from:

    namespace MyNS
    {
        class Class1
        {
            public Class1(int a)
            {
                if (a > 4)
                {
                    a += 4;
                }
     
                if (a > 4)
                {
                    a += 4;
                    a += 5;
                }
            }
        }
    }


    to 

    namespace MyNS
    {
        class Class1
        {
            public Class1(int a)
            {
                if (a > 4)
                    a += 4;
     
                if (a > 4)
    {
                    a += 4;
                    a += 5;
    }
            }
        }
    }




  2. Borislav
    Admin
    Borislav avatar
    35 posts

    Posted 24 Jun 2013 Link to this post

    Hello Patrick,

    JustCode formatter feature can only format your code without adding or removing something from it (except spaces and new lines). Its purpose is to make your code better looking.

    Fortunately JustCode has one cool feature called "Code Cleaner". One of its features is "Arrange code block usage". Executing it will add / remove blocks for certain constructs including if-else. You can setup its behavior from JustCode menu -> Options -> Code Style -> C# -> General -> section Block Usage.

    "Code Cleaner" can be executed over a given selection, single file, project or over the whole solution, using the JustCode main menu, VS editor context menu or Solution Explorer.

    More detailed information about "Code Cleaner"s features can be found in JustCode's documentation:
    http://www.telerik.com/help/justcode/introduction.html

    Hope this is what you need.

    Please feel free to contact us again if you have any questions or suggestions.

    Regards,
    Borislav
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  3. DevCraft banner
Back to Top