Reputation: 141320
How can you count the number of matches in Vim?
For instance, for the text
<?
Upvotes: 9
Views: 1940
Reputation: 11716
: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
Upvotes: 1
Reputation: 42532
Count-items describes what you are after.
:%s/<?/whatever/ng
This is the substitution command, but the n flag avoids the actual substitution.
Upvotes: 9