reddit / emacs

Is there a way to delete whitespace lines, but only at the end of entries? (Such that you don't see blank lines when trees are folded.)

Status-Detective-783 · 2022-02-23 00:20
Org mode, of course. Here's an example: * Level 1 Some text, two blank lines after some more text, two (or more) blank lines below! * Level 2 Some other text blah blah blah * Level 3 Some other text When that's folded up, it looks like this: * Level 1 * Level 2 * Level 3 I'd like all instances of two or more trailing blank lines to be condensed into one trailing blank line so I get a clean tree like this: * Level 1 * Level 2 * Level 3
graduale · 2022-02-23 02:10
Check the variable `org-cycle-separator-lines`?
Status-Detective-783 · 2022-02-23 02:22
Yes, perfect! I just set it higher: (setq org-cycle-separator-lines 5) That's all I really wanted (even though I didn't know it, lol)!
kromobrn · 2022-02-23 02:24
You can perform a simple `query-replace-regexp` to remove all blank lines but one before a heading: ``` \(^\s * \)+\(^\s * \*+\) ``` → `\2` But are you sure that what you want is not just increasing the value of the variable `org-cycle-separator-lines`?
Status-Detective-783 · 2022-02-23 02:44
Yes, the latter is what I want, thanks! Thanks for the regexp! The regexp is what I asked for, but not really what I wanted! (It's also just a little dicey to run search/replace regexp across an entire buffer... especially for a newbie like me.)
organic-bookworm · 2022-02-23 11:37
Btw, you can set it to 0 to avoid the guesswork. The docstring of the `org-cycle-separator-lines` says: Special case: when 0, never leave empty lines in collapsed view.