Sublime Forum

Indent-delimited block folding plugin - how to share?

#1

I wanted to share a plugin that I’ve been using successfully, basically unchanged, since I built it around October 2024. It’s been very beneficial to me, and I felt a bit sad nobody else could use it.

It defines a system for indent-delimited nested blocks in text files.
The plugin defines the rules for how nested blocks are determined by indent levels, and it uses the Sublime text-folding feature to actually do the folding.
It provides commands like unfolding or folding by 1 level, folding the enclosing block, etc.
It does not support persistent storage of per-file fold state. But if anyone were to add that I’d look into using it.

I use it primarily to help me work on notes files made of nested, indented bullet-point lists. But I think it can also be used to fold indented source code if you really want.
For working on this kind of file it’s usually important to also have lines wrap to the current indent level, as opposed to the left margin, but Sublime does that just fine.

I have my most-used commands bound to Stream Deck buttons:
set_enclosing_fold_to_one_level
fold_enclosing_block
fold_one_more_level
toggle_block_fold
unfold_one_more_level

Obviously keyboard bindings can work too.

I was hoping to just be able to post the plugin source file into this forum so people could take a look if it sounded interesting.
But now I’m here, it doesn’t look like that’s a thing that we do around here? Only image attachments seem to be accepted.
I’ve seen a few people post github links. My plugin isn’t on github but I might put it there if that’s the only acceptable way to share it.

0 Likes

#2

The majority of users store their plugins on GitHub, even if they don’t plan to make them publicly available. I certainly do this for all of my own locally developed plugins, as a way to maintain my own codebase.

If you want to distribute your plugin ‘more formally’ via packagecontrol, then this is a good guide: Package Control: Submitting a package | Sublime Text Community Documentation

0 Likes

#3

PS. If you simply want to post a segment python code so that people can preview the source here in the forum, you could place it in a Markdown fenced code block.

So, for example:

```py

#  Your code here

```

Becomes something like:

import sublime
import sublime_plugin


class ExampleCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, "Hello, World!")

Only do this if the code is fairly short and easy to read. I would post the whole source code for a complicated plugin in this way.

0 Likes

#4

Thanks for the reply, gbird!

The code is a single file, around 700 lines. In my judgement, probably not “fairly short and easy to read”.

After taking a closer look, it seems I’ve pushed my “Packages/User” directory to a git repository on Bitbucket. I’ll see about packaging it up in a dedicated repository with just the 1 plugin.
Thanks for your advice.

0 Likes