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?
2 Answers
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 web-mode-code-indent-offset
Javascript, Java, PHP, etc.
-
3It might be better to
customize-group
web-mode and set this. Commented Dec 26, 2017 at 23:23 -
With use-package
:
(use-package web-mode
:custom
(web-mode-markup-indent-offset 2)
(web-mode-css-indent-offset 2)
(web-mode-code-indent-offset 2))