Created
March 23, 2012 09:05
-
-
Save kosh04/2168718 to your computer and use it in GitHub Desktop.
[xyzzy]xmlを整形する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 【元ネタ】VimだけでXML Reformat | |
;; KaoriYa http://www.kaoriya.net/blog/2012/02/09 | |
;; xml-mode <http://chez-sugi.net/xyzzy/xml-mode.html> を利用して xml を整形します | |
;; ...空白にマッチする正規表現ってなかったっけ? | |
(defun xml-format-buffer () | |
"編集中のxmlをそれなりに整形する." | |
(interactive "*") | |
(labels ((%s (reg rep) | |
(goto-char (point-min)) | |
(replace-regexp reg rep t) | |
)) | |
(save-excursion | |
(%s "><" ">\n<") | |
(%s ">\\([^ \t\n\r\f\v]\\)" ">\n\\1") | |
(%s "\\([^ \t\n]\\)<" "\\1\n<") | |
(xml:xml-mode) | |
(indent-region (point-min) (point-max))) | |
t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment