comment style that tells text editors to fold sections of text
from some@programming.dev to programming@programming.dev on 03 Jul 22:37
https://programming.dev/post/33310905

I noticed that the developer of kitty terminal uses this style of comments I have rarely if ever seen elsewhere:

outside
#: section {{{
inside
#: }}}

Kate text editor recognize sections for purposes of highlighting, folding etc. It’s really nice for me because I sometimes I have a difficult time navigating large text files. And it lets you nest them.

Screenshot that shows the code folding.

I also like his style of distinguishing between narrative comments (starting with #:) and commented-out code (starting with #). Although in my example, Kate doesn’t treat them differently. Is there a term for this? Any conventions, support etc?

plain text used for screenshot

bash #: Comment level 1 {{{ #: Comment level 2 {{{ #: configure something key value #: }}} #: Another Comment level 2 {{{ #: Comment level 3 {{{ #: Helpful explanatory comment file location #: }}} #: Comment level 3 with hidden text {{{ you_cant see_this hidden_emoji “👁️” hidden_emoji2 " 👁️" hidden_emoji3 " 👁️" #: }}} #: let’s set some things up # setting yes # other_setting no different_setting maybe #: }}} # regular comment #: }}} # regular comment outside anything ___

For a real world example, see sample kitty.conf file provided on project website.

#programming

threaded - newest

HelloRoot@lemy.lol on 03 Jul 23:28 next collapse

what is this called?

Marker-based folding

thingsiplay@beehaw.org on 04 Jul 01:09 collapse

^(update: just added a new link)^

The way you describe and show it, is called foldmethod “marker”. The advantage of markers are, that they are built into the file. The disadvantage is, its built into the file. I rather like having the source independent from folding markers. The good news is, you can change the foldingmethod in Neovim and ignore the marker comments and instead use your own method.

A simple one is just “manual”, where you set what is foldable and not. There are some automatic ones, like based on indentation and such. I was never a folding guy anyway, so don’t really know all the differences when to use and how they differ. Neovim has following foldmethod: manual, indent, expr, syntax, diff, marker. The “expr” method even allows you a custom code and logic.