I am using the Vim extension in VSCode.

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


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.

  • What did you try?
    – romainl
    Commented Jan 18 at 11:46
  • 2
    Does this answer your question? How to replace each match with incrementing counter? There's several different techniques there: hopefully one of them works in VSCode.
    – Rich
    Commented Jan 18 at 12:10
  • Thz common understanding is that rhe VsCode plugin is not in the score of this site (see what is vi) but the redirection of romainl could help you partly :-) Commented Jan 18 at 12:55
  • Yes. The Vi(m)-like behavior of the plugin is on-topic, but VSCode-specific parts are not.
    – D. Ben Knoble
    Commented Jan 18 at 13:24
  • So... we close part of the question...?
    – Friedrich
    Commented Jan 18 at 18:44

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.