用于在 vim 中搜索和替换的正则表达式

问题描述:

我有一个包含多个条目的文件,如下所示:

I have a file which has multiple entries like this:

Abcd:abcd:*sometext*:klm:xyz/abc
Abcd:abcd:R%fs90uw:klm:xyz/abc

现在,我想将klm"替换为qrs",仅用于那些行中包含sometext"字符串的行.

Now, I want to replace "klm" with "qrs" for only those lines which have the "sometext" string in the line.

如何使用 vim 中的搜索和替换功能执行此操作?

How can I do this using the search and replace feature in vim?

谢谢!

:g 是你的朋友:

:g/sometext/s/klm/qrs/g