Recently, Tim Chase wrote in the thread "replace
with a number sequence":
...8<---
> Things get a little trickier if one wants to do the replacement
> in a single line of multiple instances...
>
> opInstance(1), opInstance(2), opInstance(3)
>
> One has to write a function that effects a global variable:
>
> let g:start=0
> function! Incrementer()
> let l:result = g:start
> let g:start = g:start + 1
> return l:result
> endfunction
>
> and then do something like
>
> :%s/regexp/\=Incrementer()/g
>
> It would be nice not to have to use global variables for
> something like that.
Can't one initialize the unnamed register, @" and use a :g with
a command along the lines of 'replace with @" and increment @"'
(I tried some experiments to implement the above idea but could
not do so. But my inability to implement it does not meant that
it can't be done.)
--Suresh