2

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?

2

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

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

| improve this answer | |
  • Perfect, thank you! – Charlie Martin Dec 9 '19 at 1:08
  • Knowing that js2 inherits js-mode properties is even more useful. – Charlie Martin Dec 9 '19 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.