Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom folding for Sublime Text 3

Tags:

sublimetext3

I am trying to get custom folding for sublime text 3, namely the markers:

*--#[
    some stuff
*--#]

indicate my region. I tried AAAPacakgeDev, but it doesn't seem to support folding. The package SyntaxFold introduces its own logic and new keybindings, which seems unnecessary.

It seems .tmLanguage does support folds, so what I did is I copied Obective-C.tmLanguage from its package to Packages\FORM and renamed it to `FORM.tmLanguage'. Then I modified the markers to:

<key>foldingStartMarker</key>
<string>^\*..#\[.*$</string>
<key>foldingStopMarker</key>
<string>^\*..#\].*$</string>

and changed the syntax to FORM. Even though the colors change and the pattern matches when I do a regex on the code, the folds are not working.

What am I doing wrong?

like image 986
Ben Ruijl Avatar asked Aug 06 '15 09:08

Ben Ruijl


People also ask

How do you collapse sublime?

Sublime Text has really good multiple selection support. Here's another way: select all 50 lines (with the mouse, maybe?) then press cmd+shift+right or shift+End, as above, and collapse it.

How do I hide lines in Sublime Text?

Select the text you want to hide, then from the Edit menu -> Code Folding -> Fold.


1 Answers

Apparently, this is a long-time requested feature. I found the SyntaxFold package to be a convenient substitute. My configuration file looks like:

    {
        "endMarker": "^\\*..#\\][^\n]*$",
        "name": "Form",
        "startMarker": "^\\*..#\\[[^\n]*$"
    },

I also made the key bindings the same as the normal folds.

like image 172
Ben Ruijl Avatar answered Sep 28 '22 06:09

Ben Ruijl