1

I'm having trouble with the indentation of the cases's code-blocks in my switch statements

it looks like this:

switch(var)
{
    case "case1":
    case's code line 1;
    case's code line 2;
    break;
    default:
    stuff...
    break;
}

I'd really prefer that it looked like this:

switch(var)
{
    case "case1":
        case's code line 1;
        case's code line 2;
        break;
    default:
        stuff...
        break;
}

it was working properly before, so I took a look at the mode's .el file, but I didn't understand anything so I left it there.

2
  • What is the major mode of the buffer? You can find out with C-h v major-mode while your cursor is in that buffer. There are a few possibilities (js-mode, js2-mode, js3-mode and possibly others), so it would be good to know what we are dealing with here.
    – NickD
    Jul 20, 2022 at 17:17
  • 1
    It is in js mode: major-mode is a variable defined in ‘C source code’. Its value is ‘js-mode’ Original value was ‘fundamental-mode’ Jul 21, 2022 at 22:41

1 Answer 1

0

For js-mode I set this:

(add-hook 'js-mode-hook
  (lambda ()
    (setq js-switch-indent-offset js-indent-level)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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