Code folding with Regions in Python using Kate
I once again ended up having to edit a somewhat large Python file. Since I don’t believe in Clean Code’s methodology of splitting things up into thousands of micro-functions and then having to pass tons of variables around as arguments all the time, I’m actually happy with that. Also it’s kinda what code folding was invented for. Unfortunately I usually don’t find it all that helpful, because it doesn’t fold the way I want it to.
I like what C# does with #region and
#endregion, where you can freely define a section of code
to be folded away, exactly how it makes sense to you the human,
who this feature is designed for, rather than the machine that gets to
execute the code and thinks in different patterns than you do.
So, I found a way to enable Kate to do this in Python. Here’s how.