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

Installs

  • Total 148
  • Win 66
  • Mac 49
  • Linux 33
Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7
Windows 0 0 0 0 1 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 1 0 1 0
Mac 0 0 0 1 0 0 0 0 0 0 0 0 0 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
Linux 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 0 0 0 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.