How to show line number in vi text editor

I use putty as a terminal to connect my remote server through ssh.

Vi is my favorite text editor in it.

How to display line numbers along the left side of the editor?

Enter following command while using vi text editor

:set nu

It will looks like as below:

vi-text-editor with line number


To turn off the display of line number, try

:set nu!

But most of time, I would like to set it up and keep line number display as default

How to do it?

vi ~/.vimrc

Add following line

set number

Save and close the file.