Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Display the Search Count in Vim's Status Bar

display-the-search-count-in-vims-status-bar.jpg

It's handy to know how many search results are in your buffer and which one is currently under your cursor.

Quick Jump:

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

Have you enabled this in your vimrc file? Let me know below!

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments