I have this at the end of my .emacs:
(setq-default indent-tabs-mode nil)
(setq tab-stop-list (number-sequence 2 120 2))
It works fine in other modes – whenever I tab, it adds two spaces. But in js2-mode, it adds 4.
You can set js2-basic-offset
to 2.
M-x customize-variable
js2-basic-offset
Then Apply and Save
button in the customize option buffer. This will add an item to set the variable into .emacs
or init.el
file.