[TxMt] TM variable substitution across all project files

James Fishwick fishwick.hmco at gmail.com
Thu Oct 19 22:33:20 UTC 2006


In all the files in my project, where a certain string of characters  
is present,
I'm trying to replace a string with the a part of the file name  
containing said
string.

For example, files are called ace[1-12].xml, and for everytime there  
is a the
block: "mc\d+(.*\n.*True)" I want to replace mc\d+ with tf0(number  
prefix from
filename). I know this hits on a couple more adavanced concepts I  
don't have a
full grasp on yet, but this editor is goading me on to learn regex  
and basic
command line skills...

The command I have now is:

Save: nothing

Command:
eval arr=("$TM_SELECTED_FILES")
for (( i = 0; i < ${#arr[ <at> ]}; i++ )); do
perl -pe 'while ($string =~ m/mc\d+(.*\n.*True)/g) {$string =~
s/mc\d+/tf$TM_FILENAME/g;}';
done

Input: Entire Doc

Output: Replace selected text

It's choking big time... any pointers to the numerous places I'm  
screwing up?

Thanks~



More information about the textmate mailing list