Sublime Forum

Code Folding on Multiple Indentation for DSL

#1

Hi all, I’ve built a language TM file for syntax highlighting a domain specific language and it works fine… mostly.

What I need to do is to set it up to make quick use of the code-folding hotkeys CMD+K, 1, 2, 3, CMD+K, CMD+J, etc.

Using spaces (4) and not tabs, if the second line of a block is indented once (4 spaces or less) I can quickly fold the block using the hotkeys.

However, the formatting requires that blocks are indented multiple times (see below) and in this case the quick folding doesn’t work, nor do the global fold shortcuts.

Note, manual folding using the gutter arrows or using CMD+ALT+ when inside the block still work.

Example code block:

Comment: "0000 - The following block does something awesome" # comment on the comment
01:15:00 OBJECT ACTION KEYWORD ( \ # COMMENT...
     |    |    |    PARM0001 = 1   [RAW] \ # COMMENT ...
     |    |    |    PARM0002 = 25  [RAW] \ # COMMENT ...
     |    |    |    PARM0003 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0004 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0005 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0006 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0007 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0008 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0009 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0010 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0011 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0012 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0013 = 0   [RAW] \ # COMMENT ...
     |    |    |    PARM0014 = 0   [RAW] \ # COMMENT ...

I guess I need to specify a regex for the indentation or such, but I don’t know how to go about this… all help/comments appreciated.

J.

0 Likes