Fold Code Blocks

Use case or problem

In many cases, code blocks in notes are examples or logs. You can skim through the notes more efficiently with these code blocks folded.

Proposed solution

Make code blocks able to fold and unfold, just like in VS Code.

4 Likes

This seems so obvious. I need this. I’ve tried by using headers at the top of code block, which allows you to fold everything beneath it with it. You need a fold setting enabled. The issue is that it folds everything until the next heading it seems… I just need the code block folded. I can put specific headings at the bottom to stop it but that’s a pain.

Any suggestions are appreciated

1 Like

Maybe you can try the callouts function

[!info]-
![[Document#blockreference]]

hope that helps

Creative idea!
Unfortunately it would mean every line in the codeblock needs to be prepended with the blockquote symbol, which adds another step to remove it when copy-pasting from the note.
More folding options built-in, without requiring community plugin, would be great!

2 Likes

If you setup autotext with the h6 followed by codeblock syntax, followed by h6 blank, then you only need write the title of the block after the first h6 and the code.

1 Like

This works. Thank you.
I’m using the Text Snippets plugin which I’m not sure if you were referring to.
With this snippet:
code : ###### -$nl$$end$$nl$$nl$###### -