Word Count With Vim Search and Replace
Vim's search and replace feature can count of how many times a word appears in a body of text. Take this file:
Thing
Thing
Thing
This command will count instances of Thing
:
:%s/Thing//n
3 matches on 3 lines
Here the n
flag means:
Report the number of matches, do not actually substitute.
h/t Josh Branchaud
Tweet