[TxMt] Folding PHP docblocks

Richard Dyce subscriptions at dyce.com
Fri Nov 21 10:53:13 UTC 2008


Hi,

Having a small problem changing the HTML wrapping setup to accommodate  
php docblocks.

I use alt-cmd-[ to reformat my code, and it (unsurprisingly) resets  
docblock comments to

/**
   * A comment
   **/

However, I like my coments to fold!

I've tried changing the HTML language to cope with this, but I can't  
quite get it to work. I can get

/**
* A comment
**/

to fold with :

	foldingStartMarker = '(?x)
		(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style| 
script|ul|ol|li|form|dl)\b.*?>
		|<!--(?!.*--\s*>)
		|^<!--\ \#tminclude\ (?>.*?-->)$
		|<\?(?:php)?.*\b(if|for(each)?|while)\b.+:
		|\{\{?(if|foreach|capture|literal|foreach|php|section|strip)
		|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/)))
		|^\s*/\*\*\s*$ # added for folding docblocks
		)';
	foldingStopMarker = '(?x)
		(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset| 
style|script|ul|ol|li|form|dl)>
		|^(?!.*?<!--).*?--\s*>
		|^<!--\ end\ tminclude\ -->$
		|<\?(?:php)?.*\bend(if|for(each)?|while)\b
		|\{\{?/(if|foreach|capture|literal|foreach|php|section|strip)
		|^[^{]*\}
		|^\s*\*\*/\s*$ # added for folding docblocks
		)';

But can't seem to get the two spaces before the ** on the last line to  
take.

Is there some trick with the regex I'm missing, or can I change the  
behaviour of alt-cmd-[  ?

TIA

R

--
Richard Dyce MA (Cantab.) MBCS MIET




More information about the textmate mailing list