在Vim中有效地追加一场比赛:克/ --- / S / --- / X / [英] To append a match efficiently in Vim :g/---/s/---/X/

查看:138
本文介绍了在Vim中有效地追加一场比赛:克/ --- / S / --- / X /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可以参照比赛在Vim的命令先按g

我想将X中的比赛后,无需更换比赛。
例如,在无需编写以下命令 create_title 两次。

 :克/ create_title / S / create_title / X /

您应该获得

  create_titleX

运行命令

  create_tile


解决方案

我不知道为什么你需要在命令中的先按g 部分 - 替代只会作用匹配线。下面是你在找什么:

 :%s / create_title /&安培; X /

&放大器; 重新presents这是符合整个文本

How can you refer to the match in the command g in Vim?

I would like to put X after the match without replacing the match. For instance, in the following command without writing the create_title twice.

:g/create_title/s/create_title/X/

You should get

create_titleX

by running the command to

create_tile

解决方案

I'm not sure why you need the g portion of the command - the substitute will only act on matching lines. Here's what you're looking for:

:%s/create_title/&X/

The & represents the entire text which was matched.

这篇关于在Vim中有效地追加一场比赛:克/ --- / S / --- / X /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆