zokugun / vscode-explicit-folding

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

cutting a file into blocks #16

Closed snuup closed 4 years ago

snuup commented 4 years ago

hi. i would like to fold the file

111 process xxx      <- begin
text text 
text text 
text text            <- end
222  process yyy     <- begin
text text 
text text 
text text            <- end
333  process yyy     <- begin
text text 
text text 
text text            <- end

on the "process" line boundaries. tried with lookahead regex:

"folding": {
        "log": {
            "beginRegex": "process",            
            "endRegex": "(?=^.*process)"
        }
    },

without success. any hint?

suggestion: for simple break-into-block folding as i intend to do here, it would be nice to allow specifying the begin(Regex) only.

daiyam commented 4 years ago

@snuup with the newest version (v0.6.0), you do:

"folding": {
    "log": {
        "separator": "process"
    }
}
daiyam commented 4 years ago

If you have any issue, fell free to reopen this issue.

snuup commented 4 years ago

Wow, that is really fast and cool, thank you so much. Check it as soon as its out on market place. Meanwhile read your code ;)

daiyam commented 4 years ago

read my code?

snuup commented 4 years ago

the changes you just commited.

snuup commented 4 years ago

hmm, folding does not occur on my side. i used a file with this content:

111 process xxx      
text text 
text text 
text text            
222  process yyy     
text text 
text text 
text text            
333  process yyy     
text text 
text text 
text text            

and copied exactly your settings.

"folding": {
    "log": {
        "separator": "process"
    }
},

it works on your side?

daiyam commented 4 years ago

it does but the file's extension needs to be log. You can change the "log" to "*" to work on all files but you will need to be careful with a generic separator as it is.

snuup commented 4 years ago

sure. i closed and reopened vscode, now it works. - the "window reloads" obviously did not have the same effect.

thank you so much @daiyam, that is extremely useful for me now, and i guess for other readers of text log files too ;)

retorquere commented 3 years ago

I'm trying to set this up for Python Interactive, but with this

"folding": {
      "py": { "separator": "# %%"}
    }

I don't see the folding markers for the sections.

daiyam commented 3 years ago

try:

"folding": {
  "python": { "separator": "# %%"}
}
retorquere commented 3 years ago

Superb!