Reformat XML on Emacs

You can reformat XML code adding the following code in your .emacs:

(require 'sgml-mode)

(defun reformat-xml ()
  (interactive)
  (save-excursion
    (sgml-pretty-print (point-min) (point-max))
    (indent-region (point-min) (point-max))))

And executing reformat-xml in your XML buffer then.


 09 April 2012 | emacs programming english