[TxMt] Re: snippet to generate unique ID, detect end of document, and move cursor

Stephan Hugel urschrei at gmail.com
Mon Jul 26 17:02:01 UTC 2010

On 26 July 2010 01:13, Dr. Drang <drdrang at gmail.com> wrote:
> I'll leave the unique ID for someone else to answer. As for the
> jumping back and forth in the document, take a look at this:
> http://www.leancrew.com/all-this/2006/03/markdown-links-in-textmate-the-final-frontier/
> I use reference-style links and put the URLs at the bottom of the
> document. You should be able to adapt the logic of my
> command/snippet/macro combination to the footnote syntax.

That seems to be exactly what I'm looking for. I can't seem to be able
to adapt your regex pattern to match
though. I've tried both
@nums = $text =~ /^\[\^(\d+)\]: /mg; and
@nums = $text =~ /^\[(\^\d+)\]: /mg;
Without success. Should I also be adapting:
# Escape special characters.
$text =~ s/([\$\\`])/\\$1/g;

(apologies, my regex abilities are nonexistent)
> --
> Dr. Drang
> On Sun, Jul 25, 2010 at 5:20 PM, Stephan Hugel <urschrei at gmail.com> wrote:
>> Hello,
>> I'm trying to write a snippet that will create a footnote in a TM file
>> (using markdown syntax), and I'm having some difficulties:
>> [snip]
>> So, what the snippet needs to do (theoretically) when snippet is
>> triggered: generate a (not too long, 5 digit alphanumeric should be
>> fine for a single document) unique id, and insert the full
>> [^footnote_identifier] string, then jump to the end of the document,
>> insert [^footnote_identifier]: and a space, allow typing of the
>> footnote text, then return to the original insertion point when tab is
>> pressed again.
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate



More information about the textmate mailing list