Method One ( the most embarrassing method ):
1, display the current line number, in the VI command mode input
: Nu
2, display all line numbers, in the VI command mode input
: Set nu #这是: Shorthand for set number
Method Two ( the best method ):
Using VI to edit the ~/.VIMRC file, the file does not exist automatically generate a new file, so do not worry about the existence of the file, add a line "set Nu" in the file, adding the content without quotation marks, the command is as follows:
[Email protected] ~]# VI ~/.VIMRC
#生成 the. vimrc file, enter the following in the first line:
Set number #vi, VIM is applicable! A once in a way
Method Three ( only vim effective, VI invalid!) If you want VI to take effect, use method two ):
The configuration file for VI in Ubuntu is stored in the/etc/vim directory with the configuration file named VIMRC
The configuration files for the VI in Fedora, Red Hat Linux (CentOS) are stored in the/etc directory, and the configuration file is named VIMRC
Use VI to edit the file, adding a line of "set Nu" to the file, with the added content without quotation marks. :
[Email protected] ~]# VIM/ETC/VIMRC #Fedora, Red Hat Linux (CentOS) commands
[Email protected] ~]# VIM/ETC/VIM/VIMRC #Ubentu的命令
Linux Vi/vim Edit file displays line number