emacs-prelude/vendor/yasnippet/snippets/emacs-lisp-mode/x-find-replace.yasnippet
2012-02-17 22:12:32 +02:00

18 lines
No EOL
608 B
Text
Executable file

# contributor: Xah Lee (XahLee.org)
# name: find and replace on region
# key: x-find-replace
# --
(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))
)
)