Displaying line numbers in vi/vim can be very useful for debugging code errors and to improve overall readability of a program. For example, if we are writing C program or Shell script and want to check coding mistakes after running or compiling it, turning on or off this feature may help a lot to identify coding problem.
Display line numbers in vi/vim
To display line numbers along the left side of a window, type any one of the following:
Hide line numbers in vi/vim
To turn off line number again, type the following command:
Make vi/vim show line numbers by default
The vimrc files contains optional runtime configuration settings to initialize vi/vim when it starts. On Unix/Linux based systems, the file is named .vimrc. To display line numbers every time you start vi/vim, append following line to your ~/.vimrc file:
Save and close the file, type