Guide To Folding

James Cherti has an excellent post describing how to set up a universal folding system. Folding is one of those things that I’m equivocal about. I use it all the time in Org files and couldn’t live without it. On the other hand, I’ve never seen the need for folding in code files. Sometimes it is convenient to focus on a single function but in those cases I simply narrow to the function.

Perhaps my problem is that every type of file seems to have its own folding engine with different commands and bindings. Regardless, Cherti definitely does like folding in his code buffers and like me with Org files, couldn’t live without it.

His post explains his system with dealing with folding in various types of buffers. The TL;DR is that he uses kirigami as a front end to provide a uniform interface to the myriad of folding engines. That’s pretty nice but you have to tie it to the back end engines.

That’s where Cherti’s post really shines. He provides the hooks for a large selection of file types. It’s not always obvious which engine you should use for a given file type and Cherti explains why he thinks each of his choices is the correct one.

The nice thing is that once you’ve set up and learned kirigami, you can add folding for whatever files you need simply by setting a hook. Kirigami allows you to set your own bindings for the commands so even learning Kirigami is simple.

If you’re more like Cherti than like me, and want folding for as many of your files as possible, take a look at his post. It’s really easy to set up and gives you all the folding power you’re apt to need.

This entry was posted in General and tagged . Bookmark the permalink.