Sublime Forum

Markdown header code folding keybinding

#1

If I have a markdown document with H1 headers (#), I am presented with an arrow that I can click on by the header to fold that section, however if I’m on the line for the header, Ctl+Shift+[ does not fold the section. The keybinding only folds whatever I’ve highlighted. Is there a keybinding to toggle the behavior of the arrows without having to click on them?

Thanks so much!

0 Likes

#2

The items in Edit > Code Folding may do what you want (specifically, folding level 1).

1 Like

#3

Oddly, I don’t have an option for folding level 1. I get fold all and fold levels 2-9. That menu is where I found the folding shortcut I mentioned previously.

0 Likes

#4

That’s because “Fold All” actually does “fold by level 1” in ST4 by default. This change was introduced with syntax based folding, IIRC. The real fold_all command is still available though.

Fold by level however relies on indentation based or syntax based folding. Both of which are rather limited in Markdown. So don’t expect “Fold by level” to fold sections between headers, well.

MarkdownEditing ships some logic to support that better. It overrides existing key bindings to provide a more natural folding experience, but it can’t keep in sync with the fold buttons due to lack of folding API.

1 Like

#5

fold all seems to fold every single header rather than one header, which tracks with your description. i guess i’ll keep clicking…

0 Likes