zokugun / vscode-explicit-folding

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

[Question] How to fold "numbers region"? #77

Closed Diogo-Rossi closed 2 years ago

Diogo-Rossi commented 2 years ago

I'd like to fold sequences of lines that starts with numbers, which may represent tables in the text file.

I've tried some regex but none made it right. Can someone help?

Thank you

Code Example

** Table
*SWT 
**    Sw         Krw        Krow       Pcow      
**    (adm)      (adm)      (adm)      (kg/cm2)  
0.18000000   0.00000000   0.78000000   0.000
0.21000000   0.00037461   0.70634240   0.000
0.24500000   0.00175859   0.62502470   0.000
0.28000000   0.00416233   0.54867850   0.000
0.31500000   0.00758585   0.47730360   0.000
0.35000000   0.01202914   0.41090010   0.000
0.38500000   0.01749220   0.34946800   0.000
0.42000000   0.02397503   0.29300730   0.000
0.45500000   0.03147763   0.24151800   0.000
0.49000000   0.04000000   0.19500000   0.000
0.52500000   0.04954214   0.15345340   0.000
0.56000000   0.06010406   0.11687830   0.000
0.59500000   0.07168574   0.08527445   0.000
0.63000000   0.08428720   0.05864204   0.000
0.66500000   0.09790843   0.03698101   0.000
0.70000000   0.11254940   0.02029136   0.000
0.73500000   0.12821020   0.00857310   0.000
0.77000000   0.14489070   0.00182622   0.000
0.80000000   0.16000000   0.00000000   0.000
1.00000000   1.00000000   0.00000000   0.000

** Table
*SLT 
**    Sl         Krg        Krog       Pcog      
**    (adm)      (adm)      (adm)      (kg/cm2)  
0.38000000   0.88000000   0.00000000   0.000
0.40800000   0.80231090   0.00159084   0.000
0.44200000   0.71280000   0.00780000   0.000
0.47600000   0.62858190   0.01870052   0.000
0.51000000   0.54965660   0.03429240   0.000
0.54400000   0.47602410   0.05457565   0.000
0.57800000   0.40768450   0.07955026   0.000
0.61200000   0.34463770   0.10921620   0.000
0.64600000   0.28688370   0.14357360   0.000
0.68000000   0.23442250   0.18262230   0.000
0.71400000   0.18725410   0.22636230   0.000
0.74800000   0.14537860   0.27479380   0.000
0.78200000   0.10879580   0.32791650   0.000
0.81600000   0.07750593   0.38573070   0.000
0.85000000   0.05150884   0.44823620   0.000
0.88400000   0.03080458   0.51543310   0.000
0.91800000   0.01539313   0.58732130   0.000
0.95200000   0.00527451   0.66390090   0.000
0.98600000   0.00044870   0.74517190   0.000
1.00000000   0.00000000   0.78000000   0.000

Possible Expected result

** Table
*SWT 
**    Sw         Krw        Krow       Pcow      
**    (adm)      (adm)      (adm)      (kg/cm2)  
[+] 0.18000000   0.00000000   0.78000000   0.000

** Table
*SLT 
**    Sl         Krg        Krog       Pcog      
**    (adm)      (adm)      (adm)      (kg/cm2)  
[+] 0.38000000   0.88000000   0.00000000   0.000
Diogo-Rossi commented 2 years ago

Never mind, I just figure it out.

I'll put here for reference

                    {
                        "beginRegex": "((^\\s*)\\d.*$)",
                        "nested": false,
                        "bypassProtection": true,
                        "endRegex": "^(?!(^\\s*)\\d.*).*$",
                        "foldLastLine":false
                    }