Emacs,nxhtml如何突出显示或跳转到关闭html标签?

yok*_*oko 10 emacs nxhtml

我正在使用带有nxhtml的 emacs 来编辑我的HTML文件,但是我找不到如何突出显示或跳转到结束 HTML标记?

这听起来像一个简单而愚蠢的问题,但我真的找不到它.也许我不是在找正确的事.

Xae*_*ess 13

我使用的函数来自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)
 )
)
Run Code Online (Sandbox Code Playgroud)


phi*_*ils 5

在 中nxhtml-modeC-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
Run Code Online (Sandbox Code Playgroud)

前进和后退函数是您所询问的,而向上和向下函数可让您移动到层次结构中的父元素或子元素。

sgml-mode对于 HTML(与格式良好的 XHTML 相比),答案更为稳健,但如果您要在 中使用这些函数,您可能需要为这些函数添加自动加载,nxhtml-mode因为后者不需要前者。

(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)
Run Code Online (Sandbox Code Playgroud)