Show line numbers in vi or vim

Posted: 7th January 2013 by Tim in Linux, Vim
Tags: , , , , , , ,

If you want line numbers to show up in vi or vim, this can be done by typing the following command from within the program:

:set number

or, in shorter form:

:set nu

Doing this from within vi[m] will show the numbers for that session, but they will be gone next time you start up the program. To keep them permanently, add one of the lines above without the colon, to your vimrc file. This file will be located at ~/.vimrc or /var/etc/vim/vimrc.