Reputation: 10817
I'm typing away a little html/js in Emacs using web-mode.el
<html>
<body>
<script>
var i = 0;
</script>
</body>
</html>
and I find that the line after <script>
is indented by just 1 space.
My .emacs
contains:
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(setq web-mode-markup-indent-offset 4)
(setq web-mode-css-indent-offset 4)
(setq web-mode-code-indent-offset 4)
(setq web-mode-attr-indent-offset 4)
(setq web-mode-attr-value-indent-offset 4)
(setq web-mode-indentless-elements 4)
(setq web-mode-markup-indent-offset 4)
(setq web-mode-sql-indent-offset 4)
Upvotes: 3
Views: 1885
Reputation: 10217
The variable you are looking for is web-mode-script-padding
:
(setq web-mode-script-padding 4)
If you want to do the same for <style>
tags, you can use web-mode-style-padding
:
(setq web-mode-style-padding 4)
Finally, if you want to do the same for inline server-side code, such as PHP, you can use web-mode-block-padding
:
(setq web-mode-block-padding 4)
This information can be found at Web Mode's homepage, under the Customization section. (To be fair, that page doesn't contain an example of what this code does, so it would be easy to skip over it.)
Upvotes: 6