Search and replace next n words in vi

Aubrey: 02 February 2022

Possible Duplicate:
Vim :s replace first N < g occurrences on a line (

In vi, how do I search and replace a word's first n occurrences with a word, say "hello", and the next m occurrences with bonjour, and all the rest with namaste?

Claire: 02 February 2022

Can you locate the nth "hello" manually? If so, then, I would locate the nth hello as follows:

:1 (goes to the first line of your file)
n/hello (find the nth hello, where n is the number)

Then substitute all the hellos as follows:

(move to the next line)