[TxMt] Combining snippets and commands?

Fred B. fredb7 at starflam.com
Tue Feb 28 17:48:44 UTC 2006


On 28 Feb 2006, at 17:42, Dr. Drang wrote:


>
> Clever! And if I'm reading your code correctly, you're updating  
> from the last number but still allowing the user to override, which  
> is nice.


Yes, because I sometimes use something else than numbers like e.g.  
[mail].
And if it's the first numerical reference, it proposes "1".

BTW, the second reference I make to #{n} was not necessary, I removed  
it.

#!/usr/bin/env ruby

str = STDIN.read
n = str.scan( %r{.*\[(\d+)\]: }m ).to_s.to_i + 1
print "[${1:description}][${2:#{n}}]$0" + str.gsub(/[$`\\]/, '\\\\ 
\1') + "[$2]: ${3:http://}\n"

--
FredB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20060228/41c3988c/attachment.html>


More information about the textmate mailing list