本文翻译自:vim line numbers - how to have them on by default?
我可以从正在编辑的文件中:set number
,但是默认情况下如何使它们始终处于打开状态?
#1楼
参考:https://stackoom.com/question/H6M2/vim行号-默认情况下如何启用它们
#2楼
Add set number
to your .vimrc
file in your home directory. 将set number
添加到主目录中的.vimrc
文件中。
If the .vimrc
file is not in your home directory create one with vim .vimrc
and add the commands you want at open. 如果.vimrc
文件不在您的主目录中,请使用vim .vimrc
创建一个文件,并在打开时添加所需的命令。
Here's a site that explains the vimrc and how to use it. 这是一个解释vimrc以及如何使用它的网站。
#3楼
To change the default setting to display line numbers in vi/vim: 要更改默认设置以在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 :) 我们可以获取source ~/.vimrc
或通过:wq
保存并退出,现在以后的vi / vim会话将具有编号:)
#4楼
在主目录中,您将找到一个名为“ .vimrc”的文件,在该文件中添加此代码“ set nu ”,然后保存并退出并打开新的vi文件,并在其上找到行号。
#5楼
Terminal > su
> password
> vim /etc/vimrc
终端> su
> password
> vim /etc/vimrc
Click here and edit as in line number (13): 单击此处,然后按行号(13)进行编辑:
set nu
#6楼
I'm using Debian 7 64-bit. 我正在使用Debian 7 64位。
I didn't have a .vimrc file in my home folder. 我的主文件夹中没有.vimrc文件。 I created one and was able to set user defaults for vim. 我创建了一个,并且能够为vim设置用户默认值。
However, for Debian 7, another way is to edit /etc/vim/vimrc 但是,对于Debian 7,另一种方法是编辑/ 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.