Vim tip - showing line numbers

I covered an ultra quick start on how to get into Vim recently, and now it's time for a related Vim tip.

Being a bit of a geeky text editor, Vim is often used for programming. And in programming, having line numbers easily visible can mean the difference between hunting for a bug for half an hour or finding and correcting it within a few seconds.

Now, it is possible to jump straight to a line of your choice in Vim, but sometimes it can certainly be beneficial to see the line numbers at the side for quick and easy reference. Thankfully, that is very easy to do.

In command mode, simply run the command:

:set number

To turn it back off, run its opposite number:

:set nonumber

You can also set either of these settings as your default by adding the same command to the bottom of the file .vimrc in your home directory (if it doesn't exist, simply create it).

$ cd
$ vim .vimrc

And there you go - line numbers!

Avatar for peter Peter Upfold -

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Vim tip - showing line numbers

Home » Articles » Vim tip - showing line numbers