Linux Vi/vim Edit file displays line number

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.