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

前端 未结 8 1058
迷失自我
迷失自我 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:34

    I'm using Debian 7 64-bit.

    I didn't have a .vimrc file in my home folder. I created one and was able to set user defaults for vim.

    However, for Debian 7, another way is to edit /etc/vim/vimrc

    Here is a comment block in that file:

    " All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
    " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
    " you can find below.  If you wish to change any of those settings, you should
    " do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
    " everytime an upgrade of the vim packages is performed.  It is recommended to
    " make changes after sourcing debian.vim since it alters the value of the
    " 'compatible' option.
    
    0 讨论(0)
  • 2020-12-12 09:35

    To change the default setting to display line numbers in vi/vim:

    vi ~/.vimrc
    

    then add the following line to the file:

    set number
    

    Either we can source ~/.vimrc or save and quit by :wq, now future vi/vim sessions will have numbering :)

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