Emacs 中的 HTML 标签未对齐

标签 html emacs indentation

我正在使用 Emacs 附带的 HTML 模式并编写一个基本的 index.html 页面(例如,只是一个内部带有 div 的正文)。当我尝试关闭标签时,Emacs 不会自动缩进标签以匹配开始标签。我必须在 .emacs 文件中设置某些内容吗?

问题是:

<div>
    content....
    </div>

谢谢!

最佳答案

这似乎与您所追求的类似:

Can't change Emacs's default indentation between HTML tags

有关 HTML 缩进的更多信息:

http://www.emacswiki.org/emacs/IndentingHtml

(add-hook 'html-mode-hook
  (lambda ()
    ;; Default indentation is usually 2 spaces, changing to 4.
    (set (make-local-variable 'sgml-basic-offset) 4)))

编辑:

这看起来可能是一个很好的解决方案:Can emacs re-indent a big blob of HTML for me?

By default, when you visit a .html file in Emacs (22 or 23), it will put you in html-mode. That is probably not what you want. You probably want nxml-mode, which is seriously fancy. nxml-mode seems to only come with Emacs 23, although you can download it for earlier versions of emacs from the nXML web site. There is also a Debian and Ubuntu package named nxml-mode

关于Emacs 中的 HTML 标签未对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11423588/

相关文章:

Emacs 组织模式,导出为 HTML : CLOSED timestamps?

c++ - 有什么好的方法可以控制手动缩进线之后的线吗?

javascript - Grunt 将缩进转换为空格

css - 将包含 float div 的 div 居中

javascript - 如何在不限制 'click' 、 'hover' 和 'select' 事件的情况下创建透明层?

javascript - CSS 抑制元素

html - Bootstrap 输入表单对齐

emacs - Emacs烦死了:信息太多

python - 从测试脚本中运行 pytest 测试用例

reactjs - 为什么 'create-react-app' 总是给我 2 个而不是 4 个缩进空间?