Handy textmate snippet to convert hash syntax
by tokumine
This is one of those things that I’ve known existed for years, but I’ve always avoided because of a previous irrational fear of regexes.
Sometimes you may want to go from this:
h = { :a => "b", :b => "c" .... }
to
h = {} h[:a] = "b" h[:b] = "c"
Textmate regex Find & Replace to the rescue
find
: (.*?)\s=>
replace
h[:$1] =
Voila. Textmate allows access to the matched items in the regex for substitution in to your replace string.
Advertisements