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.

TerryTsao
  • 1,176
  • 4
  • 18
  • 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 '22 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’ – Santiago Lerin Jul 21 '22 at 22:41

1 Answers1

0

For js-mode I set this:

(add-hook 'js-mode-hook
  (lambda ()
    (setq js-switch-indent-offset js-indent-level)))
rofrol
  • 186
  • 2
  • 8