Solution
I will use self-hiding paragraph styles, my example is on v24.2 but shall work on wide range of versions, just the dialogs wander a bit around.
- There are lot of default styles, including
Text Body and various Headings. They are inheriting styles from specific parents, usually leading back to Default Paragraph Style.
- Let’s create a new Style, called
Hiding 1 (there can be as many hiding category as you wish, I will only create one here), its parent should be your base style or Default Paragraph Style. This will be my base style where all hidden paragraphs will be its descendants. (If you need multiple categories of hiding, you’d cerate Hiding 2, … etc)
- Create a List style (left Styles toolbox aka F12) for header numbering if you want to number them, say,
MyHeaderList. (You need this to be able to have multiple Heading styles have the same outline level.)
- Create duplicates of the Styles you would normally use (unfortunately I see no duplicate style or copy style functionality, so you have to do it manually), make their parent
Hiding 01, and set their Outline & List properly, outline levels to matching level, List style is MyHeaderList. Practically Next style should be Hiding 1 BodyText.
You would end up something like this:
Default Paragraph style
| |
| Body Text
| |
| Heading
| Heading 1
| Heading 2 …
|
Hiding 1
|
Hiding 1 BodyText
|
Hiding 1 Heading
Hiding 1 Heading 1
Hiding 1 Heading 2
Hiding 1 Heading 3 …
I additionally set the Hiding 01 style Area to a pattern and Transparency to 90% to make all of its descendants (both body text and headers) have a visible, different background.
- Update original
Heading styles to use List style MyHeaderList as well, so your numbering will be continuous.
Now, you simply use Heading 2 for 2nd level headers and Hiding 1 Heading 2 for hidden headers, and accordingly Body Text or Hiding 1 Body Text for their body. All of them will be visible, latter with a background if you set it.
Hiding
Now hiding is real simple:
- Edit
Hiding 1 style
- Font effects » Effects » Hidden: yes (check)
- Ok
Boom, everything’s gone from view. It properly updates ToC and whatnot.
I hope it helps. 
ps
- Using
Sections is a different solution, but it’s very inconvenient to use scattered around within a document.
- Using variables didn’t work for me, and it’s pretty inconvenient anyway.
- Most of the suggestions here simply didn’t work (anymore?)