gpt4 book ai didi

html - html 的 Emacs 缩进(网络模式)不能正常工作

转载 作者:太空狗 更新时间:2023-10-29 14:53:28 25 4
gpt4 key购买 nike

我正在使用 web-mode在 Emacs 中获取 PHP 和 HTML 的语法高亮和缩进。

如果我在 .php 文件中有这段代码

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>

然后把光标放在中间那一行,按tab就什么都没有了。

我希望它看起来像这样:

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>

如果我将文本放在单行的标记中并尝试缩进,它会起作用。

这个:

<p>
<a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a>
</p>

变成这样,应该这样

<p>
<a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a>
</p>

我的 .emacs 文件

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . 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-indent-style 4)

enter image description here

最佳答案

尝试将这些设置放在钩子(Hook)函数中:

(defun my-web-mode-hook ()
"Hooks for 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-indent-style 4)
)
(add-hook 'web-mode-hook 'my-web-mode-hook)

关于html - html 的 Emacs 缩进(网络模式)不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21648629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com