my-emacs-d/elpa/yasnippet-20161022.646/snippets/emacs-lisp-mode/find-replace
2016-10-24 08:30:06 +02:00

18 lines
574 B
Plaintext

#name : find and replace on region
#contributor : Xah Lee
# --
(defun replace-html-chars-region (start end)
"Replace “<” to “&lt;” and other chars in HTML.
This works on the current region."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (search-forward "&" nil t) (replace-match "&amp;" nil t))
(goto-char (point-min))
(while (search-forward "<" nil t) (replace-match "&lt;" nil t))
(goto-char (point-min))
(while (search-forward ">" nil t) (replace-match "&gt;" nil t))
)
)