考虑以下文本文件:
something
something
something = someother thing
other thing = third thing
another thing = forth thing
Run Code Online (Sandbox Code Playgroud)
我想让它看起来像这样:
something
something
keyword something = someother thing
keyword other thing = third thing
keyword another thing = forth thing
Run Code Online (Sandbox Code Playgroud)
所以,我在每一行添加关键字,其中包含一个等号.我可以用全局命令执行此操作,或者您如何建议我应该这样做?
:g/=/s/^/keyword /
要么
:g/=/normal ikeyword
注意"关键字"后面的空格
对于这类问题,使用如下解决方案也很常见:
:%!sed '/=/s/^/keyword /'