17

In Emacs org-mode, how would I instruct org-mode to make HTML code blocks folded by default? So that when I open an org file they are folded?

incandescentman
  • 6,168
  • 3
  • 46
  • 86
  • 1
    Please see a related thread where I resolved the issue of completely hiding the `:PROPERTIES:` drawer in org-mode, along with tab-cycling for all available folding options:  http://stackoverflow.com/a/17492723/2112489   Your issue is very similar -- you would need a regexp for the beginning and ending regions of the code to be folded, and you could add that to the function in the above-mentioned link. – lawlist Feb 04 '14 at 00:28
  • I see how to enter `#+BEGIN_HTML` as a regexp, but where would I enter `#+END_HTML`? – incandescentman Feb 04 '14 at 00:31

1 Answers1

21

org-mode provides this feature out of the box. You can set it globally by customizing the variable org-hide-block-startup. To set this for a single file, add

#+STARTUP: hideblocks

To the header. Here's the relevant section of the manual

Tyler
  • 9,872
  • 2
  • 33
  • 57
  • While @lawlist's solution is a nice piece of work, this is a simpler solution, and also allows to hide/unhide with the TAB key. – incandescentman Feb 04 '14 at 23:12
  • "configuring the variable org-hide-block-startup" what does that mean? What values are possible? – xeruf Sep 24 '20 at 09:05
  • @Xerus `C-h v org-hide-block-startup` will give you the help for the variable, including a link to the customization page. The customization system is described here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Easy-Customization.html#Easy-Customization – Tyler Sep 25 '20 at 13:25
  • This doesn't answer the question. This collapses all block, not all HTML blocks – kxygk Sep 20 '21 at 07:21