VI
Editor
1. Command Mode :- In this mode you can
edit the files using basic commands.
2. Insert Mode :- In this mode you can
edit the file normally.
3. ESC Mode :- this mode is used to
escape from certain mode. Eg. Escape from insert mode and go to command mode.
Command
Mode Commands
1.
x To
delete the character.
2.
alt+u To undo the
changes.
3.
$ To take the cursor end
of the line.
4.
^ To take the cursor
start of the line.
5.
{ To take the cursor
start of the paragraph.
6.
} To take the cursor end
of the paragraph.
7.
( To take the cursor
start of the sentence.
8.
) To take the cursor end
of the sentence.
9.
w To take the cursor next
word.
10.
b To take the cursor back
word.
11.
k Used for up arrow key.
12.
j Used for down arrow key.
13.
h Used for left arrow key.
14.
l Used for right arrow
key.
15.
yy To copy a specific no.’s
of lines.
16.p To paste copied lines.
17.
dd To delete specific no.’s
of lines.
18.
shift+r or R To replace the
line
19.
r To replace the
character.
20.
o To create a blank line
below the cursor.
21.
O To create a blank line
above the cursor.
22. i Go to Insert mode
23.
:q To
exit without saving the file.
24.
:q! To
exit without saving the file forcefully.
25.
:wq To
save and exit the file.
26.
:wq! To
save and exit the file forcefully.
27. :se nu To see numbers
28: :se no nu To remove numbers
VI
editor Tutorial
1. To create file using VI
[root@server1~]#
vi filename ………
to inter into insert mode and type the following text in it
Hello!!!!!!!!
Good
Morning Everyone
Welcome
to CMS Computer Institute
ESC>
……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
[root@server1~]#
cat filename
Hello!!!!!!!!
Good
Morning Everyone
Welcome
to CMS Computer Institute
2. To Copy and Paste the lines
using Vi editor
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good Morning Everyone [ move
your cursor to specific line which you want to copy and type yy and
move your cursor were you want to paste that line
Welcome to CMS Computer Institute and type p ]
Good
Morning Everyone
PRESS ESC> ……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
[root@server1~]#
3. To Delete the lines using Vi
editor
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good Morning Everyone [ move
your cursor to specific line which you want to delete and type dd ]
Welcome
to CMS Computer Institute
Good Morning Everyone
PRESS ESC> ……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
[root@server1~]#
4. Move the Cursor end of the
line.
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good Morning
Everyone [ take
your cursor start of the line and type shift+$ to move end on the line]
Welcome
to CMS Computer Institute
ESC>
……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
5. Move the Cursor start of the line.
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good
Morning Everyone [ take
your cursor start of the line and type shift+^ to move start on the line]
Welcome
to CMS Computer Institute
ESC>
……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
6. Move the Cursor end of the
paragraph.
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good
Morning Everyone [ take
your cursor start of the line and type shift+} to move end on the paragraph ]
Welcome to CMS Computer
Institute
ESC>
……….
TO EXIT FROM INSERT MODE
:wq! ………
TO SAVE AND EXIT
7. Move the Cursor start of the paragraph.
[root@server1~]#
vi filename ………
Hello!!!!!!!!
Good
Morning Everyone [ take
your cursor end of the paragraph and type shift+{ to move start of the
paragraph ]
Welcome to CMS Computer
Institute
:wq! ………
To replace the character.
[root@server1~]#vi filename [ move
your cursor to specific word which you want to
Welcome
to CSS replace
and press r and do the changes ]
Welcome
to CMS
:wq! ………