I'm working on a javascript project that has inconsistent tab sizes 2spaces vs 4spaces on the server and client. I'm using web-mode for javascript editing. I'm looking for a feature like SublimeTexts detect_indentation

I have tried: https://github.com/emacsmirror/fuzzy-format https://github.com/jscheid/dtrt-indent

And neither have worked

  • I've had some success with dtrt-indent and javascript-mode when using Spacemacs. It doesn't look like they have bindings yet for web-mode, but if you know what variables it would need to override, it probably wouldn't be difficult to add.
    – danShumway
    Commented Jul 16, 2017 at 2:56
  • have a try with emacswiki.org/emacs/fuzzy-format.el
    – djangoliv
    Commented Oct 30, 2017 at 16:58
  • 1
    It seems that dirt-indent isn't aware of variables used by web-mode, so it would need having them added to support it.
    – user12563
    Commented Dec 29, 2017 at 13:41
  • 1
    "...neither have worked" -- please describe specifically what you have done, and detail what isn't working (what you expect, and what actually happens) with examples. Without this information, the question is very unclear.
    – phils
    Commented Aug 26, 2018 at 21:47

1 Answer 1


As Python allows to change the indent blockwise, there is related stuff in Python-modes.

python-mode.el uses py-guess-indent-offset, built-in python.el uses python-indent-guess-indent-offset

Wondering how many people are interested in generalising these proceedings.

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.