6

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;
    }
11

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

3

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

(setq js2-indent-switch-body t)

  • I'm using javascript-mode – jcubic Aug 3 '16 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.