How can I open a file with line numbers displayed from the command line in 'vi'?
Solution 1:
You can use:
vi +"set number" your_file
Solution 2:
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"
Solution 3:
You can use:
vi +set\ number <filename>
or put "set number" to your ~/.vimrc
Solution 4:
If wrongly answered your question first. My answer was:
The exact syntax, to jump to a line is :
vi +linenumber filename
or
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.