0

I am using spacemacs nXML mode to edit build.xml (java ant configuration file), the file is very long, how to fold and unfold it?

legoscia
  • 6,012
  • 29
  • 54
Daniel Wu
  • 1,711
  • 2
  • 17
  • 26
  • Here is a related link to some code folding for nXML-mode that I wrote up some time ago -- perhaps you could modify it to suit your needs. The title of the thread is **How can I fold arbitrary tags with nxml-mode?**: http://superuser.com/a/787030/206164 – lawlist Apr 15 '15 at 01:36
  • 1
    Not really what you're looking for but `set-selective-display` function can help you hide/un-hide some part of your file based on the indention. Also, `occur` is probably the best way to go when editing a large file, IMHO. – Nsukami _ Apr 15 '15 at 01:42

1 Answers1

1

You need to add this hook:

(add-hook 'nxml-mode-hook 'hs-minor-mode)

After that put this in your init.el file or somewhere it'll be loaded.

(define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding)

If you now press C-c h it will fold the xml at the element where your cursor is.

cb0
  • 1,077
  • 8
  • 11
  • 1
    I guess you need to have hs-minor-mode enabled too? Should perhaps be part of the answer. – Meaningful Username Apr 15 '15 at 09:45
  • This actually does nothing in my Emacs 24.3.1. Do I need a specific Emacs version? Or hide-show mode version? – wvxvw Apr 15 '15 at 12:32
  • I'm using emacs 24.5.1 with nothing special. You of course need to be in an xml. I'll have a look at what may be missing.. – cb0 Apr 15 '15 at 18:37