Vi, pronounced "vee-eye", is a full-screen text editor Moving Around in Vi available in . Vi allows you to view and edit text h or left arrow files and is generally one of the faster editors in terms of speed of work. Vi, however provides the user with move left one character little guidance and requires that the user knows a number of obscure keystrokes. l or right arrow move right one character Starting Vi j or up arrow Vi is invoked the UNIX prompt by typing vi move up one line filename. If the file exists, its contents are placed in the screen. If the file does not exist, a screen appears k or down arrow filled with ~ characters along the left side. move down one line

The and Edit Modes Control-d move down half screen Control-u move up half screen Vi operates in two modes, command and edit mode. When vi starts it is in command mode. In this Control-f mode you can move around using the keys j (down), k (up), h (left), and l (right). In command mode the scroll forward screens colon allows you to in additional commands. By Control-b typing : you will be taken to the command line at the bottom of the screen. From the : you can issue a scroll backward screens number of commands including wq writes the 1G go to of file file you are editing and then quits vi. G go to bottom of file Command Set G go to line # Note: n will repeat the last search, whereas 0 move to beginning of the line represents a number to be typed in that generally sets the number of times a command is repeated. $ move to end of the line The is optional, and is assumed to be 1 if not present. For example the keystroke 7x will delete forward words 7 characters from the current position. b backward words In order to type in text you need to go into the edit mode. To start editing you can type a number of keys: Editing Commands x delete a character a Start editing after the current character (append) delete a line i Start editing in front of the current r replace with next character typed character (insert) u last change A Start editing at the end of the line mx mark current line with an x (x can be any character) To return to the command mode press the escape key . ’x return to line marked with x Vi Text Editor 2 d’x delete from line marked x to current Searching line /pattern forward search for pattern y’x yank from line marked x to current line ?pattern backward search for pattern yy yank lines starting at current n repeat last search p yanked lines below current line Changing and Replacing P paste yanked lines above current line cw change words Leaving Vi cc change entire lines ZZ from vi saving changes :s/old/new/replace old string with new string on :wq exit from vi saving changes current line (replaces first occurrence on line only) :q quit from vi (only if no changes made) :1,$s/old/new/g :q! force quit from vi (without saving replace old with new globally (lines 1- changes) -$ means all lines and g means all occurences on a line.) Inserting i insert at cursor Miscellaneous o open new line below current line u undo last change O open new line above current line . repeat last change ESC exit insert mode (stop inserting) J current line and next line together Control-g report information Deleting Control-l refresh screen x delete characters :w filename file out to filename dd delete entire lines :r filename read in filename below dw delete words current line