I just installed web-mode. It works, but the indentation seems to be set to 4 spaces by default. How does one properly set it to 2 spaces?
According to the web-mode documentation, you can do that with the following:
(defun my-web-mode-hook () "Hooks for Web mode." (setq web-mode-markup-indent-offset 2) ) (add-hook 'web-mode-hook 'my-web-mode-hook)
You can also set values for
web-mode-css-indent-offset for CSS, and
This is what worked for me:
(setq indent-tabs-mode nil js-indent-level 2)
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.