No matter what I do, the customizations I apply to js2-mode are not going into effect. The mode is on and working, but with default settings. I've tried changing the default-tab-width to 2 and changing the indent behavior for switch blocks (indented case lines are turned off by default). I'm using Emacs 24.4.1.

Here are the relevant parts from my .emacs:

(add-hook 'js-mode-hook 'js2-minor-mode)
(add-hook 'js2-mode-hook 'ac-js2-mode) ;; add auto-complete suggestions

  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
  '(js2-basic-offset 2)
  '(js2-indent-switch-body t))

1 Answer 1


It looks like you're expecting js2-minor-mode to handle your indentation?

That's not the case.

C-hf js2-minor-mode RET

js2-minor-mode is an interactive autoloaded Lisp function in

(js2-minor-mode &optional ARG)

Minor mode for running js2 as a background linter.
This allows you to use a different major mode for JavaScript editing,
such as `js-mode', while retaining the asynchronous error/warning
highlighting features of `js2-mode'.

Perhaps you actually want to use js2-mode instead of js-mode as the major mode for editing javascript?

M-x find-library RET js2-mode RET

;; Installation:
;; To install it as your major mode for JavaScript editing:

;;   (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

;; Alternatively, to install it as a minor mode just for JavaScript linting,
;; you must add it to the appropriate major-mode hook.  Normally this would be:

;;   (add-hook 'js-mode-hook 'js2-minor-mode)

;; You may also want to hook it in for shell scripts running via node.js:

;;   (add-to-list 'interpreter-mode-alist '("node" . js2-mode))

;; To customize how it works:
;;   M-x customize-group RET js2-mode RET

Your Answer

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

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