The problem can be solved by the counter, separately from one built-in
:substitute: use the Vim-script variable to hold the number of matches templates. A convenient way to register each match and change a specific variable, respectively, is to take advantage of the substitution using the expression function :substitute(see :help sub-replace-\=). The idea is to use a lookup that evaluates the increment of the expression counter in each case and does not change the text that it uses on.
Ex ( \=
), :let
. gVim find/replace ", , ,
( ,
-). map()
, .
map(),
, .
,
.
, \ze \zs (.
:help /\zs, :help /\ze). ,
. , ,
- .
,
.
.
:let n=[0] | bufdo %s/pattern\zs/\=map(n,'v:val+1')[1:]/ge