Vi Editor Commands
Vi Editor Commands
the cursor A append at the end of the line i insert before cursor I insert before 1st non-blank on the same line o open and insert at line below O open and insert at line above 3) CURSOR MOVEMENT COMMANDS: j line down k line up l character right h character left w word right b word left e end of word $ end of line ^ beginning of line G go to the last line nG go to line number n H go to top of the screen M go to middle of screen L go to last line on screen ) go to next sentence ( go to previous sentence ] go to next paragraph [ go to preceeding paragraph ^f go to next screen ^b go to previous screen ^d go to next half screen ^u go to previous half screen ^l go to re-draw screen 4) CHANGE AND REPLACE COMMANDS r replace character R replace till esc is pressed CW change word CC change line SW substitute word
5)
DELETE COMMANDS x delete a character nx delete n characters dw delete word ndw delete n words dd delete line ndd delete n lines D delete till end of line ^D delete till beginning of line d/pat delete up to pattern pat d?patdelete back to pattern pat d; delete to end of sentence d( delete to beginning of line d{ delete to end of paragraph UNDO COMMANDS U undo last operation u restore the changes made to current line nP undo retrieve n last delete YANK AND PUT COMMANDS yy or Y copying the line N nyy or NY to copy n lines into memory nyw to copy n number of words in memory yw to copy single word from a line p puts the copy contents below the cursor P put the copy contents above the cursor SAVE AND EXIT COMMANDS :w save changes :x exit saving changes ZZ save and exit :q quit without saving :q! quit discarding changes :!<command> running shell from vi :!! Repeat last command
6)
7)
8)