Today I Learned

hashrocket A Hashrocket project

Count number of matches

You can use the search and replace functionality in vim to count the number of matches for that search like so:

:%s/transaction_id//n

You will see the result in the command tray like so:

8 matches on 8 lines

If you want to find matches global (that is, counting multiples per line), you can add the g flag:

:%s/transaction_id//gn

for a response like:

13 matches on 8 lines
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.