This is a minor mode that tries to enable useful folding for XML files, copying a lot from AUCTeX’s tex-fold.el. It builds on nxml-mode, and will probably break horribly if it is not the major-mode.
See the sample.html for a very simple example of what it’s supposed to do.
If you’re using MELPA, M-x list-packages RET C-s noxml-fold i x
should work.
- Get the repository:
git clone https://github.com/paddymcall/noxml-fold.git ./some_dir
- Edit your ~/.emacs:
(add-to-list 'load-path "<<./path/to/some_dir>>") (add-hook 'nxml-mode-hook (lambda () (require 'noxml-fold)))
With an open xml file, make sure you’re in nxml-mode, and load
noxml-fold with M-x noxml-fold-mode
.
The most useful entry points are noxml-fold-dwim
, and
noxml-fold-region
. For smaller files, you can also try
noxml-fold-buffer
.
There is also a kind of visibility cycling. If on the <
of an
element’s start tag, repeated <TAB>
will let you show/hide children
and contents of that element.
Since this mode uses overlays, it does not scale: for very long or deeply nested XML structures, you should only fold what’s within view (`noxml-fold-visible’), or make use of `narrow-to-region’.