使用Vim中的递增值搜索并替换
发布时间:2020-12-15 19:35:19 所属栏目:安全 来源:网络整理
导读:让我说我写了一个简单的CSS规则,如下所示: .star_10 { background: url(stars.png) no-repeat 0 0;} 我需要10,所以我复制了9次。 .star_10 { background: url(stars.png) no-repeat 0 0;}.star_10 { background: url(stars.png) no-repeat 0 0;}.star_10
让我说我写了一个简单的CSS规则,如下所示:
.star_10 { background: url(stars.png) no-repeat 0 0; } 我需要10,所以我复制了9次。 .star_10 { background: url(stars.png) no-repeat 0 0; } .star_10 { background: url(stars.png) no-repeat 0 0; } .star_10 { background: url(stars.png) no-repeat 0 0; } .star_10 { background: url(stars.png) no-repeat 0 0; } .star_10 { background: url(stars.png) no-repeat 0 0; } 等等 现在我想用增加的值来改变star_10和0,所以它看起来像这样: .star_10 { background: url(stars.png) no-repeat 0 0; } .star_9 { background: url(stars.png) no-repeat 0 -18px; } .star_8 { background: url(stars.png) no-repeat 0 -36px; } .star_7 { background: url(stars.png) no-repeat 0 -54px; } 等等… 那么我如何搜索/替换每个实例,做一个计算和写?
您可以使用宏来轻松实现。让我们说你只有这样:
.star_10 { background: url(stars.png) no-repeat 0 0; } 将光标放在第一个点(在.star10中),并在普通模式下键入以下内容: qa3yy3jp^Xjt;18^Xk0q 解释: > qa将在注册表“a”中开始宏记录。 之后,你可能会有这样的事情。 .star_10 { background: url(stars.png) no-repeat 0 0; } .star_9 { background: url(stars.png) no-repeat 0 -18; } 而已。只需将光标放在.star_9上的点上,然后按8 @ a执行多次记录的宏。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |