If you want to show the line numbers in vi editor while editing the file then you need to set the number flag. follow the steps given below to set the line numbers while using the vi editor:
Show Line Numbers in vi Editor
- First, open the file in the vi editor
[root@testserver ~]# vi /etc/httpd/conf/httpd.conf
- Press the Esc key if you are in insert or append mode.
- Press : (colon) and you will see that cursor will reappear at the lower-left corner of the screen next to the : prompt.
:
- Now type any one of the following commands and press Enter.
set number
or
set nu
- You will see that a column with sequential numbers will appear on the leftmost side of the screen as shown below.
25 # Configuration and logfile names: If the filenames you specify for many 26 # of the server's control files begin with "/" (or "drive:/" for Win32), the 27 # server will use that explicit path. If the filenames do *not* begin 28 # with "/", the value of ServerRoot is prepended -- so "logs/foo.log" 29 # with ServerRoot set to "/etc/httpd" will be interpreted by the 30 # server as "/etc/httpd/logs/foo.log". 31 # 32 33 ### Section 1: Global Environment 34 # 35 # The directives in this section affect the overall operation of Apache, 36 # such as the number of concurrent requests it can handle or where it 37 # can find its configuration files. 38 # 39 40 # 41 # Don't give away too much information about all the subcomponents 42 # we are running. Comment out this line if you don't mind remote sites 43 # finding out what major optional modules you are running 44 #ServerTokens OS 45 46 ServerTokens Prod
Hide Line Numbers in vi Editor
- Type any one of the following commands at : prompt and press Enter to hide or turn off the line numbers in the vi editor.
set number
or
set nu