[How To] Display Line Numbers In vi Editor

[Unix] Display Line Numbers in vi Editor

vi is unarguably mother of all Editors.The power and elegance of vi lies in its command line nature. While editing files, it becomes cumbersome to determine the exact position of a particular text in question.

Without any ado, let us understand how to do this in vi editor. The approach is simple and straight-forward. To enable the visibility of line numbers in vi editor, we just need to type the command ':set number' in command mode of vi editor.

:set number

 Another way of accomplishing this is by the command ':set nu'

:set nu

Alternatively, you may want to open the file by default with line numbers from the command line. Use the following syntax..

vi +"set number"

::Example::
The below example shows how to enable line numbers using :set number option


Job accomplished !!