【发布时间】:2020-07-15 14:33:59
【问题描述】:
我必须在与模式(例如字符串“foo”)匹配的行前面加上字符“*”以及以下所有以“+”开头的行。
在我正在处理的文件中,语法使用“+”作为一行的第一个字符,表示该行是前一行的一部分,例如:
this is a command line continuing through next lines and containing foo
+ this line continues the preciding one with other commands
+ this line continues the preciding one with other commands
this is a new command line
this is another command line
修改后的文字应该变成:
*this is a command line continuing through next lines and containing foo
*+ this line continues the preciding one with other commands
*+ this line continues the preciding one with other commands
this is a new command line
this is another command line
更简单的例子:
gas
foo
+ abc
+ def
+ ghi
bar
+ qwe
+ rty
baz
foo
bor
变成:
gas
*foo
*+ abc
*+ def
*+ ghi
bar
+ qwe
+ rty
baz
*foo
bor
【问题讨论】:
标签: vim substitution