Is it possible to substitute a regular expression with a randomly generated number in Vim ? The (random) number to be replaced should be different for each pattern that matches the regular expression. Here’s an example of what I need.
Input File:
<a>XYZ</a>
<a>XYZ</a>
<a>XYZ</a>
<a>XYZ</a>
After substituting XYZ with random numbers, the output could be:
<a>599</a>
<a>14253</a>
<a>1718</a>
<a>3064</a>
If you don’t mind a little perl in your vim, you can use
Edit: updated to allow unlimited substitutions on a given line, per suggestion by @hobbes3, so
Becomes something like