在确认的替代命令中捕获“是"点击次数? [英] Capture the number of 'yes' clicks in a substitute command with confirmation?
问题描述
是否可以通过确认在替代命令中捕获是"点击次数?
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屋!