set and unset line number in file with vi editor

In this tutorial we will learn, set and unset line number in file with vi editor. The same is applicable to vim editor also.(vim is advanced vi editor).vi editor is one of the famous and bydefault file editor in many linux distro. In vi editor you can use regex tricks.

To set line number in file with vi or vim editor

Open the file with vi or vim editor and type the below given command by firstly pressing ESC key

:set number

OR

:set nu

To unset or remove line number in file with vi or vim editor

:set nonumber

OR

:set nonu
:set number!

OR

:set nu!

To permanently set line number in file for user

To permanently set line number in files for user edit .vimrc file in user’s home directory

Step 1: Edit .vimrc file

vi ~/.vimrc

Step 2: Now in .vimrc file insert below given command

set number

OR

set nu

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.