vi editor commands in UNIX

Following table shows the usage and keyword of command using in vi editor.
Note: While using the keyword the cursor is not in editing mode.
(ie) It is in ESC mode.

UsageKeyword
To edit the vi file, enter into inert mode usingi
To escape from insert mode usingESC
Enter a letter after the cursor positiona
save the file:w
Quit the file:q
Quit the file without any change:q!
Save and Quit the file:wq
To goto the Beginning of a line^ or 0
To goto the end of the line$
Replace a characterr
Delete a characterx
Replace word starting from cursor positioncw
Copy a lineyy
Copy 10 lines10yy
Paste the copied data single timep
Paste the copied data 10 times10p
Paste above the cursorP
Paste below the cursorp
Delete the line starting from cursor positionD
Search a string forward/<search_word>
Search a string backward?<search_word>
To go to the next instance of the searched stringn
To go to the previous instance of the searched stringN
Undo operationu
Redo operationCtrl+r
End of the fileG or $
Start of the filegg
To reach particular line number (eg: 10):10
Enable line numbering:set nu
Disable line numbering:set nonu
Ignore the case for searching a string:set ic
To move Page upCtrl+u
To move Page downCtrl+d
Start inserting from the next lineo


Search and Replace Command:

KeywordMeaning
:%s/oldword/newword/gsearch and replace oldword by newword in the whole file
:%s/oldword/newword/gcsearch and replace oldword by newword in the whole file interactively
:s/oldword/newword/gsearch and replace oldword by newword in the current line
:s/oldword/newword/search and replace first occurence of oldword by newword in the current line