Display the Search Count in Vim's Status Bar
It's handy to know how many search results are in your buffer and which one is currently under your cursor.
Let’s say you search for /hello
and there’s 10 matches. By default Vim won’t
show you how many results were found and if you n
through them, you also
won’t be able to see where you are in the file relative to the other matches.
Wouldn’t it be nice if you could see something like [2/10]
in your status bar?
Fortunately this behavior is available in Vim. You just need to set shortmess-=S
in your config file. Here’s the
commit
for when I added it to my dotfiles.
By default Vim does set S
which is described like this in the help menu:
do not show search count message when searching, e.g “[1/5]”
In our case, we’re using -=S
which removes that option so it does show it. If
you already happen to be using shortmess+=
for something else, that’s ok. You
can set both the -=
and +=
options on separate lines.
The video below shows how it works.
# Demo Video
Timestamps
- 0:29 – Looking at shortmess
- 0:53 – Configuring shortmess
- 1:40 – The eight buffalo sentence
Reference Links
- Git commit in my dotfiles
- https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo
Have you enabled this in your vimrc file? Let me know below!