I am editing a file and i want to change only a specific word with another word, but only for first N occurrences. I tried multiple commands
N :s/word/newword/
:%s/word/newword/count
And other commands that i could find on google. But none of them works.
EDIT:: Vim commands is preferred. But Vim script can also be used. I don't have any prior experience in vim scripting.
:s/word/newword/N
is the only valid command, but that would replace the first occurrence on the next N lines. And if you used the /g flag, it'll replace all occurrences on the next N lines. Neither do the the exact count you desire.