I have for the moment the following ex command:
:let a = 1 | g/B/ s//\=printf('%02d', a)/ | let a += 1
This command replace each occurrence of B by an incremented number. But, each time the word reinitialize appear in the file, a variable should be set at 0, without modifying noting to the word reinitialize. The variable should only affect the occurrences of B.
I can add at the end | g/reinitialize/ let a = 0. But this occur the replacement of the only first occurrence of B and ignore all the following ones.
How to do this?