[TxMt] Re: TM2: Folding in plain text files

Martin Kühl martin.kuehl at gmail.com
Thu Feb 23 09:03:47 UTC 2012


On Thu, Feb 23, 2012 at 00:12, Megan Nix Nissen <megan at techcycled.com> wrote:
> In any case, it seems that the best way to accomplish my goal is to convert
> all of my text files to markdown and my brace-delimited blocks into indented
> blocks. The only method I can think of is to write a regexp and tediously
> pick through my files searching and replacing, then saving each one as
> markdown. Unless anyone else has a better suggestion..?

You could start with something like this awk script to do the indentation:

#!/usr/bin/awk -F
$0 ~ "^}" {
	indent=""
}
{ print indent, $0 }
$0 ~ "{$" {
	indent="    "
}

It indents by four spaces, leaves the braces in the text and can't
handle nested blocks, but it's a start :-)

Cheers,
Martin


More information about the textmate mailing list