masukomi / vim-markdown-folding

Fold markdown documents by section.
248 stars 43 forks source link

Less greedy fold? #25

Closed iago-lito closed 7 years ago

iago-lito commented 7 years ago

Hi and thank you for this plugin which worked out-of-the-box! :)

How hard would it be to prevent blank lines before sections to be folded? For instance, in:

1.     # Section 1
2.  
3.     ## Subsection A
4.  
5.     Here is a
6.     long
7.     long
8.     text, uh?
9.  
10.    ## Subsection B
11.
12.    Here is
13.    another one
14.
15.
16.
17.    # Section 2
18.
19.    Here is my conclusion 

.. I would like line 9. not to be folded with A, and 14. 15. 16. not to be folded with B nor 1. In this fashion, When everything is folded, we would still see the vertical white space between the sections.

SimpylFold, which folds python code based on (mostly) indentation, works this way.

This could be optional of course ;)

nelstrom commented 7 years ago

I personally like the 'greedy' folding as it is now. I like how I can collapse the entire document and read the foldtext as though it were a table of contents. I can use j and k to navigate through each header in the markdown document, and if I want to dive in to the fold I can use za to toggle it open. All of that would also be true with a less 'greedy' folding mechanism, but you'd have to use jj and kk (or zj and zk if you're feeling fancy) to get from one fold to another. The blank lines in between mean dead spots, where the za command does nothing. I can see how you might prefer the way it looks with blank lines giving a bit more breathing room, but for me the ergonomics of navigating tightly packed 'greedy' folds wins.

On the whole, I'm not a big fan of optional settings in plugins. They overcomplicate the codebase and the documentation too. If you really want this, feel free to fork the plugin and make it work however you like. I'm unlikely to accept a PR though. 😸