Author Topic: Can't get switch to format the way I like (C++)  (Read 410 times)

JimmieC

  • Senior Community Member
  • Posts: 355
  • Hero Points: 13
Can't get switch to format the way I like (C++)
« on: February 07, 2017, 08:11:32 pm »
I have changed the tabs to spaces so that formatting stay consistent when pasted into the forum.

        switch (BurstCnt)   // What I get
        {
        case    3:
            break;

        }


        switch (BurstCnt)   // What I want
        {
            case    3:
                break;

        }


patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 748
  • Hero Points: 36
Re: Can't get switch to format the way I like (C++)
« Reply #1 on: February 07, 2017, 08:36:26 pm »
You should be able to get that with the beatufier settings under Indent -> Indent Rule Exceptions -> 'case' Statements.  Turn on indent, and maybe adjust the indent width if it's different from your syntax indent.

JimmieC

  • Senior Community Member
  • Posts: 355
  • Hero Points: 13
Re: Can't get switch to format the way I like (C++)
« Reply #2 on: August 03, 2017, 12:51:52 am »
This doesn't seem to work.
Putting in a carriage return to start the case puts it correctly indented the way I want it. As soon as I type a space the case moves left.

    // Starts out good, cursor is right after the 'e' in case
    switch( i )
    {
        case
    }
    // Then put a space after the 'e' and case moves left
    switch( i )
    {
    case
    }

    The way I want format my switch statements seems to the default in Visual Studio, CCS & Boxer.
    switch(i)  // Boxer
    {
        case FIRST_CASE:
        break;
    }
    switch(i)  // OR , most of the time, I indent the break like this.
    {
        case FIRST_CASE:
            break;
           
        case SECOND_CASE:
            break;
    }

JimmieC

  • Senior Community Member
  • Posts: 355
  • Hero Points: 13
Re: Can't get switch to format the way I like (C++)
« Reply #3 on: August 03, 2017, 01:06:28 am »
Never mind.Indent had gotten turned back off. Don't know if I did it at some point or if it occurred during an update. Most likely me. Now the case statement does not move left when I put a space after it.

However, one thing that SE does not do is indent properly for the next case after the break.

    switch(i`)
    {
        case FIRST:
            break;<-- CR here
            |<-- Cursor is here. CR again
            |<-- Cursor is here
        |<-- Expected cursor to be here, to set up for next case
    }

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 748
  • Hero Points: 36
Re: Can't get switch to format the way I like (C++)
« Reply #4 on: August 03, 2017, 01:26:28 pm »
True, we don't automatically dedent after a break for C++, the 'case' won't get re-indented to the right place until you type 'case' and hit the space bar.  We do that for Python for statements that end a block.

So I'd say definitely possible, but not likely to make it for v22 at this point.

JimmieC

  • Senior Community Member
  • Posts: 355
  • Hero Points: 13
Re: Can't get switch to format the way I like (C++)
« Reply #5 on: August 04, 2017, 01:05:31 pm »
OK. I just thought I would report a small bug. If it's by design, it's fine. Not an issue.