0

I am using the Vim extension in VSCode.

I want to append every occurrence of a phrase, for example:

breadCrumbLabel

In my codebase with the instance number. The first occurrence would have to be:

breadCrumbLabel 1

the second would be:

breadCrumbLabel 2

and so on.

romainl
  • 40,486
  • 5
  • 85
  • 117

1 Answers1

0

In Vim, I would use :grep or :vimgrep to fill the quickfix list (or a location-list variant) and then use the classic

:let i = 1
:cdo substitute/$/\=' '..i/ | let i += 1

Here I’ve assumed the instances are spread out across files. If they are locally contained, any of the solutions at How to replace each match with incrementing counter? should do.

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65