[TxMt] Re: Custom Folding
John Relosa
john.relosa at yahoo.com
Wed Jul 13 15:23:20 UTC 2011
Hello,
thanks, this works ok but now every time I have any {comment}, TM shows a down
fold arrow only (since there is no {/comment} obviously.
Is there a way to have the {block}...code...{/block} folding system
differentiate from regular {comments}
It could be something like:
{<block>}
{comment on code}
code
{comment on loop}
{<loop>}
loop
code
end
{</loop}
more code
{</block>}
Only the {<...>} ...... {</...>} would have folding markers and not the regular
{comment}.
Secondly regarding the language, there is no standard folding set but it would
be nice to set up keywords that would start and end folds in user defined paired
words like
function.... end function, if...end if, on init...end on, etc... Is that
possible?
Thanks in advance.
------------------------------
Message: 4
Date: Tue, 12 Jul 2011 13:01:25 -0700
From: Dru Kepple <dru at summitprojects.com>
To: TextMate users <textmate at lists.macromates.com>
Subject: [TxMt] Re: Custom Folding
Message-ID: <882B4362-5E89-413C-AA0A-BA1FD64670DB at summitprojects.com>
Content-Type: text/plain; charset="us-ascii"
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
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20110713/5872ffed/attachment.html>
More information about the textmate
mailing list