On 28 Feb 2006, at 06:47, Dr. Drang wrote:

Thanks to the helpful comments, I was able to put together a command
and macro combination that does just what I wanted. It's described in
some detail at

http://www.leancrew.com/all-this/2006/02/textmate_and_links_again.html


Very good description on your blog!

Following your questions on the list and the answers to it, I did the same yesterday, but with Ruby. 

The only difference is that it increments the last id number and insert it instead of "id". That may interest you.

When recording the macro, I added "ctrl + L" at the end, so it centers on the caret, I which I could do that automatically after I made a new link, I don't think it's possible though...


#!/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:#{n}}]: ${3:http://}\n"