ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Inline Fold

A Sublime Text plugin that is useful to fold regions into a single line.

Details

  • 0.0.5
  • github.​com
  • github.​com
  • 8 months ago
  • 21 minutes ago
  • 11 months ago

Installs

  • Total 121
  • Win 51
  • Mac 40
  • Linux 30
Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12
Windows 1 2 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0
Mac 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

InlineFold

A Sublime Text plugin that is useful to fold regions into a single line.
It can be useful to hide long strings (for example, TailwindCSS classes).

If the cursor is on the same line where the text was folded because of the "inline_fold.rules",
the text will be shown,
else the text will be folded.

output

Set Fold Regions Globally

From the top menu, select Preferences > Settings and specify the "inline_fold.rules" setting:

Error: language “jsonc” is not supported
// Preferences.sublime-settings
{
    "inline_fold.rules": [
        {
            // Example: <div class="..."></div>
            "fold_selector": "string.quoted.single - punctuation.definition.string, string.quoted.double - punctuation.definition.string",
            "preceding_text": "class,className",
        }
    ]
}
  • fold_selector - [Required] The fold_selector is the region that will be folded.
  • preceding_text - [Optional] The region will be folded only if the preceding_text is found before the fold_selector. InlineFold will scan max one line before finding the preceding_text. Multiple words can be specified by separating them with a comma, (example "preceding_text": "class,className").

Set Fold Regions per Syntax

If a rule is specific to a particular syntax, for example, Python. Open a Python file. Click Preferences > Settings - Syntax Specific and specify the "inline_fold.rules". Those rules will only apply to Python files:

Error: language “jsonc” is not supported
// Python.sublime-settings
{
    "inline_fold.rules": [
        {
            // Example: view.run_command(...)
            // The `- punctuation.section.arguments.begin` will not fold the open bracket
            // The `- punctuation.section.arguments.end` will not fold the close bracket
            "fold_selector": "meta.function-call.arguments.python - punctuation.section.arguments.begin - punctuation.section.arguments.end",
        }
    ]
}

Examples

Here is a few examples:

Error: language “jsonc” is not supported
{
    "inline_fold.rules": [
        // Fold TailwindCSS class names
        // Example: <div class="..."></div>
        {
            "fold_selector": "string.quoted.single - punctuation.definition.string, string.quoted.double - punctuation.definition.string",
            "preceding_text": "class,className",
        },

        // [Python] Fold docstring except for the first line of the docs string.
        // class Person:
        //     """
        //     Some really long docs string. ..."""
        {
            "fold_selector": "comment.block.documentation.python - punctuation.definition.comment",
        }
    ]
}

For more example go here.