Displaying line numbers under vi / vim can be very useful for debugging code errors and to improve overall readability of a program.
vi / vim show line number command
To display line numbers along the left side of a window, type any one of the following:
(Fig.01: Vi / Vim line numbers in action – click to enlarge image)
To turn off line number again enter the same command:
If you need number every time you start vi/vim, append following line to your ~/.vimrc file:
Save and close the file.
Jump to particular line number from a shell prompt, enter:
$ vi +linenumber file.c
$ vi +300 initlib.c