[TxMt] Re: Incremental Sequences for Replacement
Hans-Jörg Bibiko
bibiko at eva.mpg.de
Tue Mar 2 20:54:47 UTC 2010
Hi,
a quick solution could be:
Create a tmcommand "increment \i":
Input: selection or document
Ouptut: replace selected text
Command:
#!/usr/bin/perl -w
$cnt=1;
$inc=1;
while(<>) {
if(m/^\\i\((\d+)\s*,\s*(\d+)\)$/) {
$cnt=$1;
$inc=$2;
next;
}
while(s/\\i/$cnt/) {$cnt+=$inc;}
print;
}
then record a macro:
1. command:
Find as regexp: (<a) (class="([^"]*)")
Replace all with: $1 id="_\i" $2
2. command:
Call "increment \i"
and save that macro.
Then you can specify at the begin of your doc a line for setting up the \i
\i(2,5)
and run the new macro.
--Hans
More information about the textmate
mailing list