2014-11-03 50 views

回答

3

我会做王子土豆烧牛肉的方式,但...

:%s/^.*Compile/<Action name="Parse" \/>\r& 

^.*Compile      " matches everything from the first char on the line 
           " up to and including 'Compile' 
<Action name="Parse" \/>\r& " replaces the match with the new desired line, 
           " followed by a newline, followed by the match 

非常优雅...

:g/Compile/t-|s//Parse 

:g/Compile/t-     " copies the matching line above itself 
:s//Parse      " substitutes the last search pattern with 'Parse' 
           " on that new line 
+0

有:%s和/ GC现在我可以有选择地更换物品 – 2014-11-03 08:53:28

2

可以使用:g命令搜索线,然后对每个匹配的行提供一个:normal!命令:

:g/Compile/normal! O<Action name="Parse" /> 

!确保在调用:normal时不会调用用户映射。

+0

工作就像一个魅力 – 2014-11-03 08:29:27