Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Didn't you answer your own question? – HTTP500 Apr 30 '12 at 12:50
@HTTP500: Hope, by now you might have understood (after reading the answers below) that my question is subtle different. – Gnanam May 2 '12 at 4:59
up vote 4 down vote accepted

You can use:

vi +"set number" your_file
share|improve this answer

How about if you create a separate vim settings file for both cases? For example, ~/.vimrc-number and ~/.vimrc-nonumber. Then you can launch those like this:

vim -u ~/.vimrc-number /some/text/file
vim -u ~/.vimrc-nonumber /some/text/file

Or create aliases to your .bashrc:

alias vimnumbers="vim -u ~/.vimrc-number"
alias vimnonumbers="vim -u ~/.vimrc-nonumber"
share|improve this answer

Looks to me like you answered your own question; Maybe you need to rephrase the question?? :D

vi +LINENUMBER nameoffile

share|improve this answer
No, the question is little different. Your command jumps to the specified line number after opening the file. But my question was, how do I specify that option at the time of opening file itself. Hope you might be clear by now. – Gnanam Apr 30 '12 at 13:34
If you mean once you open the file, you want to go to the line then you just type in :linenumber – RomeNYRR Apr 30 '12 at 14:55
Actually, my question was how to specify the option "at the time" of opening file from command-line (but not "after" opening the file). Hope I made it clear. – Gnanam May 2 '12 at 5:39

You can use:

vi +set\ number <filename>

or put "set number" to your ~/.vimrc

share|improve this answer

If wrongly answered your question first. My answer was:

The exact syntax, to jump to a line is :

vi +linenumber filename 


vi filename +linenumber

Where linenumber is a number.

And the correct answer to your question is:

vi +set\ number <filename>

Which will provides lines number while editing filename.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.