Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果它们包含特定的字符串,我正在尝试从一行中删除它们。下面是一个文本示例:
host-a, host-b, host-c+test, host-d, host-e+test
我想删除任何包含+test, 结果为:
+test
host-a, host-b, host-d
同样,我需要逐行应用它,而不是文件中的所有行。它将在宏中使用。
我怎样才能做到这一点?
像这样的东西,也许?
:%s/\<[-a-z]\++test\>//gc
如果您想替换它,它将询问每场比赛。提示:set hlsearch将向您显示匹配项。
set hlsearch
如果您还想删除逗号,则:
%s/\(,\s\+\)\?\S\++test\>//gc