简体   繁体   中英

Unable to count the number of matches in Vim

How can you count the number of matches in Vim?

For instance, for the text

<?
:%s/<?//ng

请参阅: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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM