Contents
Getting Started with the Vi Editor
Vi is a screen oriented text editor. It has 2 different modes: command and insert.
Insert mode is entered using a number of different commands, but i and a are the most common. Once in insert mode, you just type away entering new text. If you make a mistake, just use the
deletekey (Backspaceon some keyboards) to rub out. To do anything other than insert text you must get out of insert mode by pressing theescapekey. If you are unsure which mode you are in, just press theescapekey and you will be back in command mode.In command mode, you can move around in the file, delete text, search for key words, cut and paste, etc. A list of important commands is below. More information on vi is available by typing
man viTo start vi, type
vi filenameand the file will be displayed on your screen. Use the arrow keys to move around in the file.
To Do This Type This Insert and Insert text before the cursor ireplace Append text after the cursor aOpen a new line below current line oReplace char under cursor with x rxChange wordc cwGet out of insert mode [escape]Save Save file and continue editing :wDelete Delete current line ddDelete word dwDelete character xDelete rest of line DMoving Move forward one word waround Move backward one word bMove to end of line $Scroll down half screen [ctrl]dScroll up one half screen [ctrl]uJump to end of file GExiting without saving changes :q!Other Undo last change uSearch for word /wordFind next use of word nJoin lines J
Additional Resources
UNIX 101: vi Editor
vi Command Reference
Mastering the VI editor