vim line numbers - how to have them on by default?

前端 未结 8 1057
迷失自我
迷失自我 2020-12-12 09:07

I can :set number from within a file I\'m editing but how can I have them always be on by default?

相关标签:
8条回答
  • 2020-12-12 09:19

    If you don't want to add/edit .vimrc, you can start with

    vi "+set number" /path/to/file
    
    0 讨论(0)
  • 2020-12-12 09:21

    Add set number to your .vimrc file in your home directory.
    If the .vimrc file is not in your home directory create one with vim .vimrc and add the commands you want at open.

    Here's a site that explains the vimrc and how to use it.

    0 讨论(0)
  • 2020-12-12 09:21

    I did not have a .vimrc file in my home directory. I created one, added this line:

    set number
    

    and that solved the problem.

    0 讨论(0)
  • 2020-12-12 09:29

    set nu set ai set tabstop=4 set ls=2 set autoindent

    Add the above code in your .vimrc file. if .vimrc file is not present please create in your home directory (/home/name of user)

    set nu -> This makes Vim display line numbers

    set ai -> This makes Vim enable auto-indentation

    set ls=2 -> This makes Vim show a status line

    set tabstop=4 -> This makes Vim set tab of length 4 spaces (it is 8 by default)

    The filename will also be displayed.

    0 讨论(0)
  • 2020-12-12 09:30

    in home directory you will find a file called ".vimrc" in that file add this code "set nu" and save and exit and open new vi file and you will find line numbers on that.

    0 讨论(0)
  • 2020-12-12 09:32

    Terminal > su > password > vim /etc/vimrc

    Click here and edit as in line number (13):

    set nu
    

    click here and Edit as "Line number (13)"

    0 讨论(0)
提交回复
热议问题