Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
predragnikolic authored Aug 19, 2023
1 parent 96ba832 commit 6b337bc
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# InlineFold

<!--toc:start-->
- [InlineFold](#inlinefold)
- [Set Fold Regions Globally](#set-fold-regions-globally)
- [Set Fold Regions per Syntax](#set-fold-regions-per-syntax)
<!--toc:end-->
A Sublime Text plugin that is useful to fold regions into a single line.<br>
It can be useful to hide long strings (for example, TailwindCSS classes).

By default,
InlineFold will only fold string that are preceded with the word "class" or "className"
and it unfolds when the caret (or selection) touches a line.
If the cursor is on the same line where the text was folded because of the `"inline_fold.rules"`,<br> the text will be shown,<br> else the text will be folded.

![output](https://user-images.githubusercontent.com/22029477/216466685-fe0c97a2-78a0-4462-b6a5-081779cbcdcb.gif)

### Set Fold Regions Globally

From the top menu, select `Preferences > Settings` and change the `"inline_fold.rules"` setting:
From the top menu, select `Preferences > Settings` and specify the `"inline_fold.rules"` setting:
```jsonc
// Preferences.sublime-settings
{
Expand All @@ -29,13 +24,14 @@ From the top menu, select `Preferences > Settings` and change the `"inline_fold.
```

- `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 to find the `preceding_text`. Multiple words can be specified by separating them with a comma `,` (example `"preceding_text": "class,className"`).
- `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.
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:


```jsonc
// Python.sublime-settings
Expand All @@ -50,3 +46,33 @@ Click `Preferences > Settings - Syntax Specific` and specify the `"inline_fold.r
]
}
```

### Recipes

Here is a list of recipes:

```jsonc
{
"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",
}
]
}
```





0 comments on commit 6b337bc

Please sign in to comment.