If you’re like most people, you use vim to edit text files. But if you’re like me, you hate having to remember which line numbers correspond to which file. Fortunately, vim has a feature that lets you turn on line numbers automatically. Here’s how:
- Open up your vim configuration file (usually located at ~/.vimrc).
- Find the line that says “set number” and add the following after it: set number 1 ..
Vim is an extremely powerful editor, but only if you know how to use it. When you first start out, it’s like getting dumped into Minecraft survival mode — you’re gonna have to punch some trees.
In this case we can easily enable line numbers by simply typing the : character and using the following:
Well that was easy. You’ll start seeing line numbers right away.
The only problem is that the next time you open vim the line numbers will be gone and you’ll have to google how to do this again and then type the command every time. Luckily there’s a way to make settings stick.
Just open up your vimrc file with vim ~/.vimrc and add the command in there. Save and exit and the next time the line numbers will be there again.