[TxMt] Re: Custom Folding
Dru Kepple
dru at summitprojects.com
Tue Jul 12 20:01:25 UTC 2011
A basic folding pattern could be set up like this:
foldingStartMarker = '\{([^\/]+)\}';
foldingStopMarker = '\{\/.+\}';
This won't be smart enough to match the text in between the curly braces, but as long as you use the slash to mark an end comment, it should be pretty workable. TextMate will handle nesting as you'd probably expect it to, so this:
{block}
code
{loop}
loop
code
end
{/loop}
more code
{/block}
Should fold as you'd want it to.
Do you have standard folding set up for the language? I don't know what language you're using, but folding is usually set up for things like functions and loops, so that's helpful, too. But I mention it because if you have to add the above markers into an existing language grammar that already has markers set up, you'll need to do them like this:
foldingStartMarker = 'otherMarker|\{([^\/]+)\}';
Note the vertical pipe in between the new addition and the existing marker; that's the regex "or".
Also, worth noting that TextMate only matches folds if the start and stop markers are at the same indent level, not merely if the marker is matched. You might get some interesting folding results with the additions combined with goofy indentation.
+dru
On Jul 12, 2011, at 11:12 AM, John Relosa wrote:
Hello,
Excuse my newbie question but I am trying to do custom folding in the language that I am working on and can't figure out how.
Comments in this language start and end with { comment..... } Anything else is compilable.
Is there a way to specify something like
{Start of code block}
code
.
.
.
.
{/End of code block}
Thanks
John
_______________________________________________
textmate mailing list
textmate at lists.macromates.com<mailto:textmate at lists.macromates.com>
http://lists.macromates.com/listinfo/textmate
More information about the textmate
mailing list