In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to open and close the line number of vi in linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Open and close line number
There are many options in the vi editor that control the look and feel of the editing session. Use the: set command to modify the session settings in vi. After pressing Escape to enter command mode, you can use the: set all command to display a list of options and settings.
One of the options you can set is number, which turns line numbers on and off (see listing 1).
Listing 1. # # Internet host table#::1 localhost127.0.0.1 localhost loghost192.168.0.6 centos5192.168.0.10 appserv192.168.0.11 webserv192.168.0.12 test192.168.0.5 solaris10 # Added by DHCP~~~:set number before opening the line number
This command causes vi to display the line number on each record in the currently edited file. After putting vi into command mode, type: set number and press enter to open the line number (see listing 2).
Listing 2. After opening the line number, 1 # 2 # Internet host table3 # 4:: 1 localhost5 127.0.0.1 localhost loghost6 192.168.0.6 centos57 192.168.0.10 appserv8 192.168.0.11 webserv9 192.168.0.12 test10 192.168.0.5 solaris10 # Added by DHCP~~~:set number
You can turn off the line number using the: set nonumber command. You can also use the abbreviations of this command and the: set number command, namely: set nu and: set nonu.
Displaying line numbers can be very helpful if you need to quickly calculate the number of lines to be processed with the vi function. Line numbers are especially useful when there are a large number of lines that may span multiple screens. In addition, sometimes you know the range of lines to deal with, but you need to find out the initial and ending line numbers to use in the vi command.
If you want the line number to be displayed every time you enter a vi session, add the set number line to the .exrc file in the home directory.
This is the end of the article on "how to open and close line numbers in vi in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.