vim does not find and replace simple phrase that is clearly present

VimReplaceScope Resolution

Vim Problem Overview


I have a simple vim problem that Google hasn't managed to help me with. Any thoughts are appreciated.

I do the following search and replace:

:s/numnodes/numnodes1/g

On a file containing the following text:

numprocs=0  
numnodes=0

I get

E486: Pattern not found

The position of the green square which indicates where I'd start typing is clearly above the pattern. I tried searching for other short phrases not involving regex, which are also present, which also fail. A simple /numnodes highlights matches as expected. Does anyone have any idea what might be the matter with vim?

Vim Solutions


Solution 1 - Vim

Try :%s/searchphrase/replacephase/g

Without the % symbol Vim only matches and replaces on the current line.

Solution 2 - Vim

try using this:

:%s/numnodes/numnodes1/g

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMark C.View Question on Stackoverflow
Solution 1 - VimmmccombView Answer on Stackoverflow
Solution 2 - VimUku LoskitView Answer on Stackoverflow