Search code examples
emacsorg-modefolding

org-mode folding considers whitespace as content


Disclaimer: I am new to org-mode.

In org-mode, I sometimes add extra empty lines to make the separation between different tasks clearer when they are expanded. Like so:

** Task 1

*** Subtask 1.1
    text text
*** Subtask 1.2

** Task 2

The problem is that when I fold 'Task 1' (by pressing C-tab while on its line) the subtasks and their contents are folded correctly, but the content of 'Subtask 1.2' is also folded (namely, the new line under it).

If I press C-tab while on the line of 'Subtask 1.2', the message 'SUBTREE (NO CHILDREN)' is printed and 'Subtask 1.2' is correctly not folded.

Is this normal? Can I somehow correct this behaviour so that empty content is not folded?


Solution

  • Use (setq org-cycle-separator-lines -1) in your config file. This will fix it.

    Documentation:
    Number of empty lines needed to keep an empty line between collapsed trees.
    If you leave an empty line between the end of a subtree and the following
    headline, this empty line is hidden when the subtree is folded.
    Org mode will leave (exactly) one empty line visible if the number of
    empty lines is equal or larger to the number given in this variable.
    So the default 2 means at least 2 empty lines after the end of a subtree
    are needed to produce free space between a collapsed subtree and the
    following headline.
    
    If the number is negative, and the number of empty lines is at least -N,
    all empty lines are shown.