22

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.

  • what is this called?
  • are there other ways to do it?
  • is it standard among text editors? I believe Kovid the dev for kitty is a vim guy so presumably there is support there also.
  • why don't more people use it? are there problems?

Screenshot that shows the code folding.

  • Cursor is at the end of line 7 so the whole section line 7-22 is highlighted
  • lines 12-16 are folded in a 3rd level comment
  • I also included tab indents just to make it easier to see what's going on (Kate treats it the same way regardless of indents)
  • Highlighting/Mode > Scripts > Bash

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


#: 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.

you are viewing a single comment's thread
view the rest of the comments
[-] HaraldvonBlauzahn@feddit.org 4 points 2 days ago

It's often better to split code in smaller functions tho, and give these good names.

[-] some@programming.dev 1 points 1 day ago

I am probably a bit over the top with this tbh. I put everything in functions, even single-use activities like declaring initial variables at the beginning. I just do it to enable the code folding. Even though everything I do is small time and I'm sure it's not excessively burdensome on the system, it seems wasteful to me to have the computer hold a the function in memory when it's never going to get used again. So I was thinking this might be more efficient in such cases.

this post was submitted on 03 Jul 2025
22 points (100.0% liked)

Programming

21381 readers
206 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS