[英]How can I indent inline Javascript in web-mode?
I'm typing away a little html/js in Emacs using web-mode.el 我正在使用web-mode.el在Emacs中键入一些html / js
<html>
<body>
<script>
var i = 0;
</script>
</body>
</html>
and I find that the line after <script>
is indented by just 1 space. 并且我发现<script>
之后的行仅缩进1个空格。
My .emacs
contains: 我的.emacs
包含:
(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)
The variable you are looking for is web-mode-script-padding
: 您要查找的变量是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
: 如果要对<style>
标签执行相同的操作,则可以使用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
: 最后,如果要对内联服务器端代码(例如PHP)执行相同的操作,则可以使用web-mode-block-padding
:
(setq web-mode-block-padding 4)
This information can be found at Web Mode's homepage , under the Customization section. 可以在Web Mode的主页 “ 自定义”部分下找到此信息。 (To be fair, that page doesn't contain an example of what this code does, so it would be easy to skip over it.) (公平地说,该页面不包含此代码的示例,因此跳过它很容易。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.