28 April, 2010

Counting occurrences of a pattern

Use the :s substitute command with the n flag (counts number of hits; no changes occur) to count the number of occurrences of a pattern. For example:
:%s/pattern//gn

No comments: