0% found this document useful (0 votes)
11 views3 pages

Demovi

Uploaded by

arehojayega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Demovi

Uploaded by

arehojayega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Changes done by root account

This is a Header line


---------------------
line1
line2
line3
line4
LINE5 is updated now LINE5 is updated again LINE5 is updated once again
line6
line7
line8
line9
line3
line4
LINE5 is updated now LINE5 is updated again LINE5 is updated once again
line6
line10
line3
line2
line3
line4
LINE5 is updated now LINE5 is updated again LINE5 is updated once again
line3
line4
LINE5 is updated now LINE5 is updated again LINE5 is updated once again
line6

A Tab Character follows and at the end of every line is the end of the line or new
line character

Adding text:
------------

esc i can be used to insert text


esc o can be used to open a blank line next to the current line
esc O can be used to open a blank line above the current line
esc x can be used to delete a single character at current cursor position
esc nx where n is a number can be used to delete n characters
esc r can be used to replace a character. Place the cursor on the character, press
esc r and then type the new character
esc A can be used to add characters at the end of the line
esc u can be used to undo the last operation

cut/copy paste:
---------------

esc dd can be used to delete the current line


esc ndd where n is a number can be used to delete n lines including the current
line

esc yy can be used to copy the current line


esc nyy where n is a number can be used to copy n lines including the current line

esc p can be used to paste the deleted or copied line(s) next to the current line
esc P can be used to paste the deleted or copied line(s) above the current line

Navigating to different lines in the file:


------------------------------------------
esc G can be used to go to the last line in the file
esc nG where n is a number can be used to go to the nth line in the file

Finding Text:
-------------

Press the esc key followed by / and when you see / in the last line, specify the
text that needs to be found

line5 --> The search will proceed in the forward direction and you will go to
the line with next match for "line5"

n --> Pressing n will continue the search in the forward direction and
you will go to the line with the next match for "line5"

N --> Pressing N will continue the search in the backward direction and
you will go to the line with the previous match for "line5"

Finding and Replacing Text:


---------------------------

Press the esc key followed by : character and when you see a : character in the
last line, execute the following commands.

%s/line5/LINE5 --> This will replace the first occurrence of "line5" with "LINE5"
in the different lines. The second and subsequent occurrences of this pattern in
the different lines will not be replaced.

%s/line5/LINE5/g --> With the global switch, this will replace each and every
occurrence of "line5" with "LINE5"

Session Customization:
----------------------

Press esc key followed by : and when you see a : character in the last line, the
following commands can be executed for the purpose specified against them.

se nu --> To set line number display on


10 --> To go to the 10th line in the file
25 --> To go to the 25th line in the file
$ --> To go to the last line in the file
se nonu --> To set line number display off

set list --> To see the Non-Printable Characters like the Tab and the new line
characters
set nolist --> To go back to the default setting where we will not see the Non-
printable characters like Tab and the newline characters

Saving and Exiting out of the vi Editor session:


------------------------------------------------

Press the esc key followed by : and when you see a : character in the last line,
the following commands can
be executed.

w --> Write (save) the file. You will still remain in the vi Editor session.
wq --> Write (save) the file and Quit (exit). You will exit out of the vi Editor
session and return to the Command Prompt
q --> Quit without saving the changes
q! --> Quit forcefully without saving the changes
wq! --> Forcefully Write and Quit with saving the changes

You might also like