Vim has an awesome feature that allows users to delete contents of tags, within quotation marks, etc. For example, in the following situation:
<h1> Cursor is here -> █ <- :) </h1>
one can type d i t (“delete in tag”) to delete the contents of the <h1>
HTML tag.
There are also other shortcuts, for example:
()
""
.''
.Does anything like this exist for Emacs?
I'm aware of zap-to-char
and nXhtml's sgml-delete-tag
, but they don't quite do what I want.
How's this code work for you?
(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)))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With