7

I'm using default javascript mode and the switch..case look like this:

    switch (component) {
    case 'action-message':
        result = actionMessage(response);
        break;

    case 'action-confirmation':
        result = actionConfirmation(response);
        break;

    case 'action-error':
        result = actionError(response);
        break;

    case 'field-error':
        result = fieldError(response);
        break;

    default:
        result = undefined;
        break;
    }

How can I make it look like this:

    switch (component) {
        case 'action-message':
            result = actionMessage(response);
            break;

        case 'action-confirmation':
            result = actionConfirmation(response);
            break;

        case 'action-error':
            result = actionError(response);
            break;

        case 'field-error':
            result = fieldError(response);
            break;

        default:
            result = undefined;
            break;
    }
jcubic
  • 691
  • 1
  • 4
  • 16

2 Answers2

13

You can set the variable js-switch-indent-offset to 4.

jrm
  • 412
  • 3
  • 9
3

If you're using js2-mode, the js2-indent-switch-body var should be set at true:

(setq js2-indent-switch-body t)

hs0ucy
  • 31
  • 3