Next: , Previous: , Up: Common requests   [Contents][Index]

5.19 How do I change the indentation for switch?

Many people want to indent their switch statements like this:

f()
{
  switch(x) {
    case A:
      x1;
      break;
    case B:
      x2;
      break;
    default:
      x3;
  }
}

To achieve this, add the following line to your init file (see How do I set up an init file properly?):

(c-set-offset 'case-label '+)