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@summitprojects.com To: TextMate users textmate@lists.macromates.com Subject: [TxMt] Re: Custom Folding Message-ID: 882B4362-5E89-413C-AA0A-BA1FD64670DB@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@lists.macromates.commailto:textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
-
You could easily customize the folding patterns. It would be up to you to decide what your convention would be; just add those angle brackets in to the pattern and you should be on your way.
You can also easily add more folding patterns. If I'm understanding your request right, you could simply match on "function" and "end function", etc, you just need to map them all out. So, combined, something like this:
foldingStartMarker = '{<[^/]+>}|^(loop|function|if|on init)'; foldingStopMarker = '{</.+>}|^(end (loop|function|if|on))';
If you want to add more folding matches following the "X/end X" pattern, just add a pipe and the "X" to the parts in both expressions that look like this:
(loop|function|if|on init)
Hope that helps, +dru
On Jul 13, 2011, at 8:23 AM, John Relosa wrote:
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@summitprojects.commailto:dru@summitprojects.com> To: TextMate users <textmate@lists.macromates.commailto:textmate@lists.macromates.com> Subject: [TxMt] Re: Custom Folding Message-ID: <882B4362-5E89-413C-AA0A-BA1FD64670DB@summitprojects.commailto:882B4362-5E89-413C-AA0A-BA1FD64670DB@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@lists.macromates.commailto:textmate@lists.macromates.com<mailto:textmate@lists.macromates.commailto:textmate@lists.macromates.com> http://lists.macromates.com/listinfo/textmate
-
_______________________________________________ textmate mailing list textmate@lists.macromates.commailto:textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate