在确认的替代命令中捕获“是"点击次数? [英] Capture the number of 'yes' clicks in a substitute command with confirmation?

查看:30
本文介绍了在确认的替代命令中捕获“是"点击次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过确认在替代命令中捕获是"点击次数?

Is it possible to capture the number of 'yes' clicks in a substitute command with confirmation?

p.e.

:%s/foo/bar/gc
replace with bar (y/n/a/q/l/^E/^Y)?

y 点击次数 = ?

推荐答案

如果你想知道做了多少次替换(y 的次数),在询问所有出现次数确认后,你会见X行Y行替换X就是你想要的.

If you want to know how many substitutions were done (the number of y), after all occurrences confirmation were asked, you will see X substitutusions on Y lines, the X is what you want.

如果您正在编写脚本并且想要获取脚本中的编号.你可以在你的函数中实现这个计数器,也可以在 :s/../../gc 之前实现,redir @x 在所有替换完成之后,重定向结束.阅读@x,取最后一行,提取^\d\+,这就是数字.

If you are writing a script and you want to get the number in your script. You can either implement this counter in your function, or before the :s/../../gc, redir @x after all substitutions were done, redir END. Read @x, take the last line, extract ^\d\+, that would be the number.

这篇关于在确认的替代命令中捕获“是"点击次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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