[TxMt] Re: snippet to generate unique ID, detect end of document, and move cursor
plastichairdoo
plastichairdoo at gmail.com
Mon Jul 26 17:20:03 UTC 2010
had a look - very cool!
it strikes me that a variation on this could possibly be used to solve my earlier problem of selecting paragraphs with a keystroke that ONLY selects to the beginning and end characters (as opposed to entire beginning and ending lines with all the spaces and 'returns')
if that's not clear you can look at my earlier question that I posted a few days ago.
since MY regex skills are even *less* than nonexistent =p I'd be intensely grateful if someone like yourself took this on as a project. it seems on the face of it that it would be an easy enough conversion from your current script... just without the bracket delimiters.
OR - if that's not possible - perhaps you could use your script as it is and simply have the macro delete the brackets after the block is selected?
just thinking about ways to speed up the workflow - no mouse allowed!
cheers,
bennett
On Jul 26, 2010, at 10:02 AM, Stephan Hugel wrote:
> 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
> [^n]:
> 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
>>
>
>
>
> --
>
> steph
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
More information about the textmate
mailing list