如何在Emacs中删除HTML标记的内容

a p*_*erd 9 html vim emacs keyboard-shortcuts text-editor

Vim有一个很棒的功能,允许用户删除标记内容,引号等.例如,在以下情况:

<h1>  Cursor is here -> ? <- :)  </h1>
Run Code Online (Sandbox Code Playgroud)

可以键入d i t("在标签中删除")以删除<h1>HTML标记的内容.

还有其他快捷方式,例如:

  • d i ( 删除括号中的内容 ()
  • d i "删除双引号中的内容"".
  • d i '删除单引号中的内容''.

Emacs有这样的事吗?

我知道zap-to-char和nXhtml sgml-delete-tag,但他们并没有完全按照我的意愿行事.

Tre*_*son 5

这段代码对你有用吗?

(defun sgml-delete-tagged-text ()
  "delete text between the tags that contain the current point"
  (interactive)
  (let ((b (point)))
    (sgml-skip-tag-backward 1)
    (when (not (eq b (point)))
      ;; moved somewhere, should be at front of a tag now
      (save-excursion 
        (forward-sexp 1)
        (setq b (point)))
      (sgml-skip-tag-forward 1)
      (backward-sexp 1)
      (delete-region b (point)))))
Run Code Online (Sandbox Code Playgroud)