[TxMt] Re: Custom Folding

Dru Kepple dru at summitprojects.com
Wed Jul 13 17:58:39 UTC 2011


Sure.  In the bundle editor, look for a Preference, probably called "Smart Typing Pairs" or something similar.  It might look like this:

{ smartTypingPairs = (
( '"', '"' ),
( '(', ')' ),
( '{', '}' ),
( '[', ']' ),
( '“', '”' ),
( "'", "'" ),
);
}

Basically, it's just a series of pairs.  You can add

( "<", ">"),

to the list and that should do it.

On Jul 13, 2011, at 10:19 AM, John Relosa wrote:


That works great thanks!

Is there a way to autocomplete the < symbol? I can do it with the { so when I press "{" TM autocompletes it with the end } so it automatically becomes {}. How can I add that functionality to the "<" symbol so it automatically becomes <>.

Thank you.

___________________________________________

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.

_______________________________________________
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