1

I get the following:

   var 
   a = 5,
   b = 6, 
   c = foo();
   /* code continues */

I want:

   var 
       a = 5,
       b = 6,
       c = foo();
   /* OUTDENT, code continues */

I know as per How to get js-mode to properly indent continued (compound?) var declarations? there is some hack for js2-mode which gets it done. I would like to know how to do it with javascript-mode (the built-in one, into emacs 24). "var" should indent one level until the first semicolon after var. Comma-first-style should not alter that.

Ideally, I could have it in my init.el, which I could then sync to every computer I am working on. Is that possible? How do I do it?

1 Answer 1

1
  1. Put a = 5 on the same line as var. Otherwise, there's no mode that supports this.

  2. Use Emacs trunk. The bit of indentation code from js2-mode that does this has been committed to js-mode just recently, and it was too late for 24.3. Alternatively, just use a recently released Emacs, and copy js.el from the Emacs source tree to a directory in your load-path.

Sign up to request clarification or add additional context in comments.

1 Comment

I have compiled emacs trunk, and it works (--version says 24.3.50.1). Thanks.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.