This is a migrated thread and some comments may be shown as answers.

Basic If Block Formatting

1 Answer 25 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick Barranis
Top achievements
Rank 1
Patrick Barranis asked on 24 Jun 2013, 01:55 AM

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;
}
        }
    }
}




1 Answer, 1 is accepted

Sort by
0
Borislav
Telerik team
answered on 24 Jun 2013, 12:49 PM
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.
Tags
General Discussions
Asked by
Patrick Barranis
Top achievements
Rank 1
Answers by
Borislav
Telerik team
Share this question
or