How can you count the number of matches in Vim?
For instance, for the text
<?
:%s/<?//ng
See :h count-items
.
Count-items describes what you are after.
:%s/<?/whatever/ng
This is the substitution command, but the n flag avoids the actual substitution.
:help count-items
In VIM 6.3, here's how you'd do it:
:set report=0
:%s/<?/&/g # returns the count without substitution
In VIM 7.2, here's how you'd do it:
:%s/<?/&/gn # returns the count without substitution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With