vi editor is used to modify the file contents.
Vi editor visual editor
Opening file $ vi [file name]
If the file is not found the editor creates a new file.
To modify the file contents vi editor provides three types of modes Command mode
input mode
exit mode
1. Command mode It is default mode. In this mode we can execute the commands of vi editor. If you are in another mode in order to get into command mode press “Esc” key.
Command to modify the file contents
A To append the text at the end of the line.
I To insert the text at the beginning of the line.
a To append the text to the right of the cursor position.
i To insert the text to the left of the cursor position.
Cursor Navigations
l To move right
h To move left
j To move down
k To move up
0 (zero) Works like home key
$ Works like end key.
b goes to beginning of previous word
4b moves four words backward
w goes to beginning of next word
5w five words forward
e goes to end of the word
3e goes to end of third word
Ctrl + f go to next page (page down)
Ctrl + d go to previous page (page up)
gg to move beginning of the file
G end of the file Commands to deletion of text dd To delete a line
4dd To delete 4 lines
cc to clear the text in a line with out deleting a line so we can enter the data in that line.
dw to delete a word
3dw to delete 3 words
x to delete a character
5x to delete 5 characters
u Undo the transaction
Opening Lines O to open a line above the cursor position
o to open a line above the cursor position