We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free. Anti-spam check. Do not fill this in!== Custom command == To quickly count the occurrences of a pattern, add the following to your vimrc: <pre> command -nargs=1 Count :%s/<args>//gn </pre> You can then run <code>:Count foo</code> to get a response identical to <code>:%s/foo//gn</code>. Unless you have another custom command starting with C, shortened versions of Count e.g. <code>:C foo</code> will also work. Summary: Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA Cancel Editing help (opens in new window) Retrieved from "https://vim.fandom.com/wiki/Count_number_of_matches_of_a_pattern"