Thanks to my co-worker for showing me this really cool trick in TextMate!
I have this project I’m working on where I need to represent enum values as text for analysis purposes. The enum though is not set up to be easily iterated over (Dr. Dobbs) (James Kanze), so I added a stream operator to do the job.
Now, using TextMate, it’s easy to use the Macro recorder to perform a text insert operation over a small enum. However, I came across a large one that would make this process way too cumbersome.
enum {
kFirstConstant = 0x001000,
kSecondConstant = 0x001002,
kThirdConstant = 0x001004,
[...]
kTwoHundrethConstant = 0x001216,
};
Thanks to my co-worker, he showed me how I can easily modify my text using TextMate‘s Search and Replace feature on left-justified code:
Find:
^(\w+)(.+)$
Replace:
else if (enumvalue == $1)
\tstringrep = "$1";
Yeah, TextMate is wicked awesome…
Yes it is 🙂