Is there a succinct way to separate folds, open or closed, by the same number of newlines throughout the buffer? I'm using fold by indent. The goal is two visible blank lines between each fold (actually, after the end of a fold, since folds will abut non-folds). So if there is one blank line it adds another, and if there are three or more blank lines, it removes blank lines down to two. I would like these as actual inserted or removed characters as opposed to mere visual updates. Enforcing this automatically would be nice but I'm fine having it mapped to a command for manual reformatting. Spaces between a final fold and the EOF are nice but optional.
Before, with non-uniform spacing:
HEADER 1
--------
- closed fold -----------------------------------------------------------
HEADER 2
--------
opened fold
opened fold
HEADER 3
--------
- closed fold -----------------------------------------------------------
HEADER 4
--------
opened fold
opened fold
opened fold
HEADER 5
--------
- closed fold -----------------------------------------------------------
~ EOF
After, with uniform spacing:
HEADER 1
--------
- closed fold -----------------------------------------------------------
HEADER 2
--------
opened fold
opened fold
HEADER 3
--------
- closed fold -----------------------------------------------------------
HEADER 4
--------
opened fold
opened fold
opened fold
HEADER 5
--------
- closed fold -----------------------------------------------------------
~ EOF