Vim note

本文介绍了Vim编辑器中用于替换字符串的两种命令。第一种是g/pattern/s/old/new,该命令针对文件中包含特定模式的所有行进行替换操作。第二种是%s/old/new/g,作用于全文所有行,将old替换成new,并在整个文件范围内进行全局替换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.  :g/pattern/s/old/new

The first g tells the command to operate on all lines of a file. pattern identifies the lines
on which a substitution is to take place. On those lines containing pattern, ex is to
substitute (s) for old the characters

old could be regular expression


2.  :%s/old/new/g

% indentifies all lines

s substitudes command

"old" could be regular expression


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值