0

This morning, my Emacs changed its indentation rules, and now it indents by 2 spaces, specifically in JS and HTML. It even re-indents code on which I work to 2 spaces, which is unacceptable.

Please help. I need 4 spaces indentation. Please help.

What I have in my init file (none work, obviously)

(setq c-basic-offset 4)
(setq-default indent-tabs-mode nil)

(custom-set-variables

 '(tab-stop-list (quote (4 8 12)))
 '(tab-width 4))
3
  • 1
    Your JS and HTML modes most likely don’t use c-basic-offset. Read the manuals for the modes in question, figure out the variables they use for indentation, and make sure they’re set accordingly
    – nega
    Mar 20 '19 at 17:00
  • 1
    As nega says, the c- in c-basic-offset indicates that it has to do with the major mode for C (and derivatives, admittedly). tab-width affects the way TAB chars are displayed, and tab-stop-list is only used in modes which don't do automatic indentation.
    – Stefan
    Mar 20 '19 at 17:19
  • 1
    "This morning, my Emacs changed its indentation rules" -- not by itself, it didn't. Tell us what you changed or installed or updated between this morning and when it last worked.
    – phils
    Apr 27 '19 at 1:27
1
(custom-set-variables
 '(js-indent-level 4))
1
  • 1
    custom-set-variables is a special operation normally inserted and managed by Custom, so better not use it manually (you risk seeing it unexpectedly erased by Custom). E.g. Just use (setq js-indent-level 4) instead.
    – Stefan
    Mar 28 '19 at 0:32

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.