Vim can display line numbers on the left side of the text but is typically not by default.
You can set Vim to display line numbers by following any of the following methods;
While in Vim, press the ESC key to get into command mode.
Type the following to enable line numbering, followed by Enter;
:set number
Vim will now display the line number on the left side of the text.
To disable it, type the following while in command mode, followed by Enter.
:set nonumber
And the line number is gone.
To make the setting permanent, add the following line to /etc/vimrc or ~/.vimrc using your favorite text editor.
set number
Vim will read the configuration file every time it's started and will display the line numbers.
Comment anonymously. Login not required.