Search code examples
emacsfoldingcode-folding

Hiding comments with hs-hide-level in Emacs hide-show mode


When I use hs-hide-level, it only hides code blocks at at the current level, but leaves comment blocks at the same level open. For example, if I take the following un-folded code:

top level code {
    /* Level 2
     * Multi-line
     * Comment
     */
    level 2 code block {
        Code inside
        level 2
        block
    }
}

And I use the hs-hide-level inside the top-level block, I will get

top level code {
    /* Level 2
     * Multi-line
     * Comment
     */
    level 2 code block { ... }
}

but I want

top level code {
    /* Level 2 ... 
    level 2 code block {...}
}

Solution

  • I don't know if this feature only appeared since the question was asked, but there is the option hs-hide-comments-when-hiding-all, which according to the documentation does this:

    Hide the comments too when you do an hs-hide-all.