I decided just to rewrite the whole command, to make it easier to fix and maintain in the future. But when I used your substitution, it didn't seem to fix anything with the '$' problem:
#!/usr/bin/env perl
# get current line, and break into what is left and right of caret
$line = $ENV{'TM_CURRENT_LINE'};
$index = $ENV{'TM_LINE_INDEX'}; $line =~ /^(.{$index})(.*)$/; $left = $1; $right = $2;
# Escape special characters since we will paste as snippet $left =~ s/(?=[$`\])/\/g; $right =~ s/(?=[$`\])/\/g;
$left =~ s/(?<!\)$/\$/m;
# Print out left and right sides to see how it's working so far (routine is not finished yet) print "$left\n\n$right\n";
If I leave out the "$left =~ s/(?<!\)$/\$/m;" line (my original substitution, it doesn't work. When I add it back, it does.
What am I doing wrong here?
F-
On Mar 15, 2008, at 10:59 PM, Allan Odgaard wrote:
On 16 Mar 2008, at 03:35, Allan Odgaard wrote:
[...] So probably this regexp subst. is more appropriate:
s/(?=[$`\])/\/
Actually, that was crafted as a global subst. and not iteratively run on the line, as your code did.
Probably would be best to just count matches (for your $add_to_index) and then run this subst. with /g (and it seems for perl, you need to escape $ even when inside a character class).
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate