I'm editing React .jsx
files, and I don't want to indent on newline, how to disable it?
Asked
Active
Viewed 1,084 times
5

Salah Eddine Taouririt
- 24,925
- 20
- 60
- 96
-
Which version of Emacs are you using? – ChrisGPT was on strike Mar 29 '15 at 13:40
-
1In that case it's probably `electric-indent-mode`, not `js2-mode`, that is automatically indenting on newline. Try turning that off with `M-x` or `(electric-indent-mode -1)`. – ChrisGPT was on strike Mar 29 '15 at 14:29
2 Answers
9
M-x electric-indent-local-mode
should do it if you're using Emacs-24.4.

Stefan
- 27,908
- 4
- 53
- 82
-
1Is there a way to automatically set this for all js2 buffers, but leave all other buffers alone? – Roger Binns Jul 17 '15 at 01:05
-
2The answer I gave only works on the current buffer. So you can add it to your `js2-mode-hook`, as in: `(add-hook 'js2-mode-hook (lambda () (electric-indent-local-mode -1)))` – Stefan Jul 19 '15 at 23:30
0
What seems to work in Emacs 25.1.1 is setting electric-layout-mode
to -1
.
So In js2-mode-hook
add:
(add-hook 'js2-mode-hook (lambda () (electric-layout-mode -1)))

chief
- 1