[TxMt] Snippets and Unix fun

Benjamin Jackson ben at incomumdesign.com
Fri Feb 24 04:14:34 UTC 2006


Hi all,

Just put this together and thought I'd share:

$TM_SELECTED_TEXT`echo "$TM_SELECTED_TEXT"|ruby -00 -pe  
"gsub(/([._]|\W)(?: 
(x)|(y)|(X)|(Y)|(width)|(height)|(w)|(h)|(Width)|(Height))/) { \$1 +  
(\$2 ? \"y\" : \$3 ? \"x\" : \$4 ? \"Y\" : \$5 ? \"X\" : \$6 ?  
\"height\" : \$7 ? \"width\" : \$8 ? \"h\" : \$9 ? \"w\" : \$10 ?  
\"Height\" : \$11 ? \"Width\" : \"\") }"`

It will take, for example, something like this:

var xMin = (this.trap_mc) ? this.target_mc._x - bounds.xMin : 0;
var xMax = (this.trap_mc) ? this.target_mc._x + this.target_mc._width +  
(this.trap_mc._width - bounds.xMax);

And append this afterwards:

var yMin = (this.trap_mc) ? this.target_mc._y - bounds.yMin : 0;
var yMax = (this.trap_mc) ? this.target_mc._y + this.target_mc._height  
+ (this.trap_mc._height - bounds.yMax);

This is something I do by hand like, maybe 10 or 20 times in a coding  
session. Anyone else have some useful additions (or a more elegant  
regexp)? ;)

- Ben
___________________
Ben Jackson
Diretor de Desenvolvimento

ben at incomumdesign.com
http://www.incomumdesign.com




More information about the textmate mailing list