vimtricks.wiki Concise Vim tricks, one at a time.

How do I see the search match count in the statusline?

Answer

:set shortmess-=S

Explanation

The shortmess option controls which messages are shortened. Removing the S flag shows the current match count (e.g., [3/15]) when searching.

How it works

  • :set shortmess-=S enables the search count display
  • When you search with / or n, the count appears
  • Shows [current/total] format

Example

After searching /error:

/error [3/15]

This shows you are on the 3rd of 15 total matches.

Tips

  • Available in Vim 8.1.1270+ and Neovim
  • The count updates as you press n and N
  • :set shortmess+=S hides the count again
  • :%s/pattern//gn is an alternative for counting matches
  • Some statusline plugins show this information as well

Next

How do you yank a single word into a named register?