Vim: Show Line Count in Visual Mode

This post was migrated from my Techblog.

Last year, I worked a great job writing little scripts. My office machine (an ancient thing running Windows 2000) had a gvim installation with an incredibly cool feature I had never seen anywhere else: it showed you how many lines you had highlighted in visual mode.

At the time, I, alas, completely took it for granted. Only several months after I left did I start wondering how I could get that feature back. Many hours of googling yielded nothing, so I fell back to my last line of defense: the Nabble vim forum.

Now, let me pause to say that this vim forum has been one of the best things I’ve ever used. I’ve posted two or three questions so far and gotten a helpful response within 24 hours of each. To the people who hang around places like that and answer my questions, my personal thanks and a big fat hug!

Anyway, I posted my question on the forum and like clockwork, I got a response: set showcmd. I slapped that in my vimrc and I’ve been enjoying my lovely line counts since. For those of you interested in what exactly showcmd is supposed to do, I copied this out of vim help:

Show (partial) command in the last line of the screen. Set this option off if your terminal is slow.

In Visual mode the size of the selected area is shown: - When selecting characters within a line, the number of characters. - When selecting more than one line, the number of lines. - When selecting a block, the size in screen characters: {lines}x{columns}.