formatastyle

Is it possible to break `case xx : {` into two line with AStyle?


I need to format following code

switch(i) {
    case 1: {
            printf("a");
            break;
        }

into:

switch(i) {
    case 1: 
        {
            printf("a");
            break;
        }

with keeping the k&r bracket style on other situations. How could I do this?

I have tried --style=kr --indent-cases


Solution

  • regex to replace:

    s/\(case.*:\s\+\){/\1\r{/g