Unable to count the number of matches in Vim

倖福魔咒の 提交于 2019-12-23 08:00:07

问题


How can you count the number of matches in Vim?

For instance, for the text

<?

回答1:


:%s/<?//ng

See :h count-items.




回答2:


Count-items describes what you are after.

:%s/<?/whatever/ng

This is the substitution command, but the n flag avoids the actual substitution.




回答3:


: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


来源:https://stackoverflow.com/questions/647049/unable-to-count-the-number-of-matches-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!