OK, I'm currently in a state of absolute boredom. And it's been 10 days since the last post on the Off-Topic forum. On my daily routine of exploring the dark and moist corners of computing, I stumbled on this Perl one-liner (I'm including the part used to call it from vi, just to make it more beautifully cluttered):
Code: Select all
:'<,'>!perl -pe '$i||=0;s/(billy)9/\1$i/;++$i'
This will take a block of text selected on vi and replace the first occurrence of 'billy9' on a line by 'billy0', the second on other line by 'billy1', and so on. 'billy' here is completely random: it's there just to replace the also completely random word I needed to replace on my code (and it's the name of my dog). And just to increase the unusefulness of this post, here is a prettier, more cluttered and more efficient version:
Code: Select all
:'<,'>!perl -pe '$i||=0;s/(?<=billy)9/$i/;++$i'
Have a nice day.