[TxMt] Folding for markdown: how?

Allan Odgaard throw-away-1 at macromates.com
Fri Oct 28 18:19:54 UTC 2005


On 27/10/2005, at 21.11, Tom Lazar wrote:

> as I was scrolling through my looong GTD project list that I keep  
> in TextMate using markdown I thought it would be convenient if I  
> could do some folding at the h1, h2, h3 levels to get a better  
> overview.
>
> could somebody here please "smack me on the head" and give a quick  
> pointer on where to start implementing that? I'm not lazy - just  
> clueless ;-)

Well, you should start by identifying the fold start and stop marker.

I'm afraid there's no logical stop marker for Markdown headers, and  
since Markdown doesn't support comments (AFAIK) there's really no way  
to add it [1]

You can manually fold them though, and you can semi-automate this by  
doing something like a regexp search for: ^#+.*$(?m:.*?)(?=^#+.*$)

This should select next header, then F1 to fold that, cmd-G to select  
next, F1, …

You can record the search + fold into a macro and maybe save with a  
key. Also, TextMate will remember what you folded upon reload (unless  
you disabled FS meta data)


[1] You could of course make your own convention, and add post- 
processing to Markdown.pl



More information about the textmate mailing list