Emacs,nxhtml如何突出显示或跳转到关闭的HTML标记?

10
我正在使用Emacs和nxhtml编辑HTML文件,但是我找不到如何突出显示或跳转到关闭的HTML标签?
这似乎是一个简单且愚蠢的问题,但我真的找不到它。也许我没有寻找正确的东西。
2个回答

14

我使用sgml-mode中的函数:

  • Ctrl+c Ctrl+f (sgml-skip-tag-forward)
  • Ctrl+c Ctrl+b (sgml-skip-tag-backward)

您始终可以将它们重新映射为更方便的快捷键,例如:

(add-hook 'html-mode-hook
 (lambda ()
 (define-key html-mode-map (kbd "<M-left>") 'sgml-skip-tag-backward)
 (define-key html-mode-map (kbd "<M-right>") 'sgml-skip-tag-forward)
 )
)

5
nxhtml-mode 中,C-hm 应该显示如下绑定:
<C-M-down>  nxml-down-element
<C-M-left>  nxml-backward-element
<C-M-right> nxml-forward-element
<C-M-up>    nxml-backward-up-element

您所询问的是前进和后退功能,而上下功能则允许您在层次结构中移动到父元素或子元素。

sgml-mode 的答案对于 HTML(而不是格式良好的 XHTML)更加强大,但如果您将在 nxhtml-mode 中使用它们,则可能需要为这些函数添加 autoloads,因为后者不需要前者。

(autoload 'sgml-skip-tag-forward "sgml-mode"
  "Skip to end of tag or matching closing tag if present.
With prefix argument ARG, repeat this ARG times.
Return t if after a closing tag." t)

(autoload 'sgml-skip-tag-backward "sgml-mode"
  "Skip to beginning of tag or matching opening tag if present.
With prefix argument ARG, repeat this ARG times.
Return non-nil if we skipped over matched tags." t)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接