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