This is just an overview of some of what vi (pronounced vee-eye) can do. It is by no means an exhaustive coverage of this workhorse of the UNIX community. Although quite old, vi has lasted because it's consistent across platforms, very powerful, simple, and much easier to use than 'ed' in its line editor mode, called ex, when doing system file repair. Think of ex as vi with only one line visible at a time. There is also read only vi, called view.
vi has 3 modes, command mode, insert mode, and line mode (also known as 'ex' mode). You are in command mode when you first start vi. You enter insert mode when you enter one of the several insert commands. Line or ex mode is entered from command mode by typing a colon ':', which brings you to a command line at the bottom of the screen. Since it's a full screen editor, vi needs to have a correct display variable set; if it does not understand the display environment, vi will enter into ex instead.
Insert Modes: (Use ESC to get back to command mode.)
i = insert before cursor, a = append after cursor.
I = Insert at beginning of line. A = Append to end of current line.
o = open blank line below cursor for text, O = above line open.
s = delete character at cursor and substitute text.
S = delete line and substitute text.
R = overstrike existing characters with new characters.
Edit Commands:
cw = change a word (overwrite mode). ESC to exit.
cc = change the entire current line. Exit with ESC.
C = change from current position to end of line, same as c$.
r = replace one character
dw = delete word. dd = delete current line.
D = delete from current position to end of line.
x = delete a character at current position.
X = delete character before cursor (like a backspace).
ZZ = write file and quit vi.