zokugun / vscode-explicit-folding

Customize your Folding for Visual Studio Code
MIT License
103 stars 14 forks source link

Python fold on indent and symbol at the same time #69

Closed tothedistance closed 2 years ago

tothedistance commented 3 years ago

Describe the issue

I need to fold to () when calling functions with lots of parameters. but on the other hand, I need to fold according to indentation.

To reproduce

Code Example

def func(
    var 1,
    var 2,
):
    some code
    more code
    fold to here

result = func(
    var 1,
    var 2,
)

Settings

"folding": {
  "*": {
    "begin": "(",
    "end": ")",
  }
}
daiyam commented 3 years ago

For Python, you can try:

"[python]": {
  "explicitFolding.rules": [
    {
      "beginRegex": "\"\"\"",
      "endRegex": "\"\"\"",
    },
    {
      "separatorRegex": "#\\s*%%"
    },
    {
      "begin": "(",
      "end": ")",
    },
    {
      "indentation": true,
      "offSide": true
    }
  ]
},
daiyam commented 3 years ago

@tothedistance Were you able to try the settings?

daiyam commented 2 years ago

@tothedistance +1

ymoslem commented 2 years ago

This works well. Thanks! I even added this to fold on commented blocks.

    {
      "separatorRegex": "#\\s*"
    },
tothedistance commented 2 years ago

For Python, you can try:

"[python]": {
  "explicitFolding.rules": [
    {
      "beginRegex": "\"\"\"",
      "endRegex": "\"\"\"",
    },
    {
      "separatorRegex": "#\\s*%%"
    },
    {
      "begin": "(",
      "end": ")",
    },
    {
      "indentation": true,
      "offSide": true
    }
  ]
},

works great. didn't know why the email notification come to me so late