Thomas Aylott (subtleGradient <oblivious@...> writes:
You could write some sort of ruby script to parse the text you just entered
and generate the code. ...
Or you could write a really complex snippet using multiple instances of the
same variable.
Thanks for your kind reply Thomas, I do not know Ruby although I know some Python. Do you think I need to invest time to learn Ruby in order to manipulate TextMate or should I stick to Python?
Anyway, here is a snippet that I came up with.
// Class: ${1:ClassName} // Instance Variables: ${2:var1}, ${3:var2}
// $1.h #import <objc/Object.h>
@interface $1: Object { int $2; int $3; } -(void) set${2/(\w+)/\u$1/}: (int) $2Val; -(void) set${3/(\w+)/\u$1/}: (int) $3Val; -(int) $2; -(int) $3; @end
// $1.m #import "$1.h"
@implementation $1; -(void) set${2/(\w+)/\u$1/}: (int) $2Val { $2=$2Val; } -(void) set${3/(\w+)/\u$1/}: (int) $3Val { $3=$3Val; } -(int) $2 { return $2; } -(int) $3 { return $3; } @end