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

大兔子大兔子 提交于 2019-12-03 06:27:52

问题


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?


回答1:


Try :%s/searchphrase/replacephase/g

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




回答2:


try using this:

:%s/numnodes/numnodes1/g


来源:https://stackoverflow.com/questions/5289262/vim-does-not-find-and-replace-simple-phrase-that-is-clearly-present

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!