Linux – How to open a file with line numbers displayed from the command line in ‘vi’

command-line-interfacelinuxvi

I've seen so many examples/usages about how to display/hide line numbers in vi edit mode.

To turn on line numbers: Type :set number in edit mode

To turn off line numbers: Type :set nonumber in edit mode

I wonder whether there is any convenient way/option available (that I may not be knowing) to specify/mention this option at the time of opening the file from the command line?

NOTE: For example, to go to a specific line inside a file after opening it, we can conveniently say vi +/<linenumber> <filename> from the command line.

Best Answer

You can use:

vi +"set number" your_file