[TxMt] folding comment blocks

Allan Odgaard list at macromates.com
Tue Oct 4 21:26:05 UTC 2005


On 04/10/2005, at 22.32, Caio Chassot wrote:

> I'd love to be able to fold comment blocks. (I'm thinking ruby, but  
> really, any language)
>
> I suppose it'd be possible with a simple modification somewhere in  
> the language bundle. Any pointers?

It's the foldingStartMarker and foldingStopMarker (for each language  
grammar in the bundle editor). These are regular expressions matched  
against each line, and those lines which match one (but not both) of  
them, becomes a start or stop marker.

One caveat being that start and stop markers must have the same  
indent to be foldable.

So for Ruby comments you'd have to make up some convention, like  
using + on first comment line and - on last, e.g.:

     #+
     #  This is a comment block
     #  which automatically folds
     #-

Which would be foldable by using these patterns:

     foldingStartMarker = '#\+';
     foldingStopMarker = '#-';





More information about the textmate mailing list