Indentation-based Folding for TextMate

Posted by Craig Walker on Super User See other posts from Super User or by Craig Walker
Published on 2011-03-10T16:04:02Z Indexed on 2011/03/10 16:12 UTC
Read the original article Hit count: 296

Filed under:
|

SASS and HAML have indentation-based syntax, much like Python. Blocks of related code have the same number of spaces at the start of a line.

Here's some example code:

#drawer
  height: 100%
  color: #c2c7c4
  font:
    size: 10px
  .slider
    overflow: hidden
    height: 100%
    .edge
      background: url('/images/foo') repeat-y
      .tab
        margin-top = !drawer_top
        width: 56px
        height: 161px
        display: block

I'm using phuibonhoa's SASS bundle, and I'd like to enhance it so that the various sections can fold. For instance, I'd like to fold everything under #drawer, everything under .slider, everything under .edge, etc.

The bundle currently includes the following folding code:

foldingStartMarker = '/\*|^#|^\*|^\b|^\.';
foldingStopMarker = '\*/|^\s*$';

How can I enhance this to fold similarly-indented blocks?

© Super User or respective owner

Related posts about regex

Related posts about textmate