3

This is pretty simple but it's thwarting me:

this is how a switch statement indents in js2-mode

  switch(letterGrade){
  case "A+":
    value = 100  ; break;
  case "A":
    value = 97 ; break;

this is how I want it to indent:

  switch(letterGrade){
    case "A+":
      value = 100  ; break;
    case "A":
      value = 97 ; break;

How can I make that happen? And, as a side question, why doesn't js2-mode use the same indenting stuff as other C-like languages?

1 Answer 1

4

js2-mode derives from js-mode. So you need set up js-mode in this case.

(setq js-switch-indent-offset 2) is enough.

2
  • Perfect, thank you! Dec 9, 2019 at 1:08
  • Knowing that js2 inherits js-mode properties is even more useful. Dec 9, 2019 at 1:10

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.