如何在vim中全部替换_在Vim中,如何在视觉选择中进行搜索和替换?

如何在vim中全部替换

Search and replace in the whole text in Vim can be done by :%s/from/to/gc. But how to search and replace in visual selection only?

在Vim中搜索和替换全文可以通过:%s/from/to/gc 。 但是,如何仅在视觉选择中进行搜索和替换?

The %V atom in Vim restricts a pattern so that it matches only inside the visual selection.

Vim中的%V原子限制了模式,因此它仅在视觉选择内匹配。

So, your command for searching and replacing only in the visual selection can be

因此,仅在视觉选择中用于搜索和替换的命令可以是

:%s/%Vfrom/to/gc

In addition, you can use marks for the beginning and end of the visual selection as the start,end range for the :s command:

另外,可以将标记用于视觉选择的开始和结束,作为:s命令的start ,end范围:

'<  start line
`<  start character
'>  end line
`>  end character
Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/in-vim-how-to-search-and-replace-in-visual-selection/

如何在vim中全部替换

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值