Today I Learned

hashrocket A Hashrocket project

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:


This command will count instances of Thing:

3 matches on 3 lines

Here the n flag means:

Report the number of matches, do not actually substitute.

h/t Josh Branchaud

See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.