41: How do I indent switch statements like this?
Many people want to indent their switch statements like this:
f()
{
switch(x) {
case A:
x1;
break;
case B:
x2;
break;
default:
x3;
}
}
The solution at first appears to be: set c-indent-level to 4 and
c-label-offset to -2. However, this will give you an indentation spacing
of four instead of two.
The solution is to use cc-mode (bundled with Emacs 19, but not the
default mode) and add the following line:
(c-set-offset 'case-label '+)
There appears to be no way to do this with the old c-mode.