How to display line numbers in vi/vim text editors

Displaying line numbers in vi / vim text editors can be very helpful for debugging code errors and to improve overall viewing of a program or a file.
How to display line numbers in vi/vim text editors

To display line numbers along the left side of a window, type any one of the following:
:set number
or
:set nu

To turn off line number again enter the same command:
:set nu!
If you need number every time you start vi/vim, append following line to your ~/.vimrc file:
set number
Save and close the file.
Jump to particular line number from a shell prompt, enter:
$ vi +linenumber file.c
$ vi +300 initlib.c

This entry was posted in Linux and tagged . Bookmark the permalink.