Sublime Forum

Code folding - doesn't use tmbundle foldingStartMarker?

#1

It seems that Sublime uses tmbundles for language definitions. When I was using TextMate, I modified the PHP.tmLanguage bundle so I could exclude comments from the code folding start/stop markers (foldingStartMarker / foldingStopMarker).

This way I could leave comments unfolded, but fold the functions and methods below them, like in the following code:

/**
 * Comment is here (unfolded even if I do a 'fold all').
 */
function my_function_here() {
  // This function would be folded if I did a 'fold all').
}

I changed the values in the PHP bundle for Sublime to what’s below, but it seems to have no effect. The only thing I could find in Googling is an old/deprecated documentation page saying that those values weren’t actually used by Sublime… but I would assume Sublime has some way to define start/stop markers for code folding, right?

Current code for folding:

	<string>^#!.*(?&lt;!-)php[0-9]{0,1}\b</string>
	<key>foldingStartMarker</key>
	<string>(\{\s*$|&lt;&lt;&lt;HTML)</string>
	<key>foldingStopMarker</key>
	<string>(^\s*\}|^HTML;)</string>

For TextMate, being able to customize my folding markers was a handy solution for my particular code folding needs (see: http://stackoverflow.com/questions/7689965/collapse-all-php-functions-in-textmate). Am I missing something here?

Alternatively, is there some other way for me to only fold functions/methods, and not the comments above them?

0 Likes

#2

I know this thread is ancient, but it’s the first hit on Google when you search for “sublime text foldingStartMarker”, so… linking this here. I’m also putting the word “foldingStopMarker” here for Googlers.

2 Likes