Line count in Notepad

Sometimes you need to count the number of lines in a plain text file. And sometimes notepad is all you have. Here’s how to do a line count in notepad.

line count in notepad
To line count in Notepad, you just abuse the Go To function, which is in Edit > Go To, or you can hit CTRL-G.

Notepad has no menu option to do a line count. The functionality is buried in there, but it’s hiding as part of another function. Unlike slightly more powerful text editors, it does not have any indicators on the screen to tell you what line and or column you are on.

To find out what line you are on, use the goto function. To count the total number of lines, scroll to the end of the document, or page down or use the end key, or whatever your favorite way is to get to the end of the document, and then use the go to function. I hit CTRL-G, because I’m a keyboard guy. But you can also navigate to Edit > Go To in the pull down menu. When the Go To dialog box comes up, the current line number is the default.

Yes, it’s two steps. It’s not the best thing ever. But we are talking Notepad here.

What to do when Go To doesn’t work in Notepad

When the CTRL-G function doesn’t work  and the go to function is grayed out and disabled in the menu, it’s because you have word wrap enabled. This function doesn’t work in conjunction with word wrap. So to enable the Goto function, navigate to Format > Word Wrap and disable word wrap. Now you’ll be able to goto and count lines.

This addition isn’t exactly something new

Notepad didn’t always have this function, so I don’t blame you if this is the first you’ve heard of it. I learned it during the XP/2003 era. Many of my retro machines are in storage right now so I can’t verify every Windows version. It was in XP, but was not in Windows 3.0.

I distinctly remember having this function on my servers but not on my workstation, but that was because I usually kept word wrap enabled on my workstation. Exactly when it was introduced probably doesn’t matter, because any supported version of Windows has it. Not to mention a whole bunch of retro versions of Windows.

You may ask why not just install a more powerful text editor, because there are plenty of them, and that’s fair. But in some environments, you have to jump through a lot of bureaucratic red tape to install any software that didn’t come as part of Windows or isn’t on a predefined software bill of materials. This may be due to the extra steps often required to keep third party apps up to date, a stigma around open source software, or just the difficulty of writing governance policies that allow useful software while keeping spyware and malware out.

It was when working in environments with very strict IT governance that I learned this trick. So if that’s what you’re dealing with, it helps to know how to do things like get a line count in notepad. Because sometimes notepad is all you get.

If you found this post informative or helpful, please share it!