Talstr. 25, D-63322 Rödermark
Tel. +49 6074 881056, FAX 881058
You may use this information free of charge at your own risk
In order to understand vi it is important to know that vi is comprised of two parts: ex and vi. ex is a line based editor built into vi using commands just like MS-DOS edlin. Because of this vi has three modes: Movement Mode, Edit Mode and Command Mode. When started vi is in Movement Mode. vi needs to be told which terminal type you are using. Normally this is detected during login and stored in the environment variable TERM but Microsoft's telnet is often detected as "ansi" when it really should be "vt100". In order to change this type before starting vi: export TERM=vt100
In Movement Mode you can move the cursor, delete lines relative to your cursor and many more things. Some actions in Movement Mode will switch vi to Edit Mode or Command Mode.
n lines of text at cursor position
if n is omitted only the current line is deleted.
|delete character under cursor
|replace character under cursor with next key pressed
|enter Edit Mode and Replace at current position
|enter Edit Mode and Insert at current position
|insert line below current line, then enter Edit Mode and Insert
|insert line above current line, then enter Edit Mode and Insert
Command Mode is enabled by typing colon (":") or ("/") and some other possible keys when in Movement Mode.
|quit vi discarting changes made
|write file and then quit vi
|search next occurence of "string".
|search and replace all occurences of "search" with "replace".
What you can do in Edit Mode heavily depends on the terminal emulation you use. I urgently recommend to use DEC VT220 or better. DEC VT100 or ANSI just isn't good enough, really. With DEC VT100 you won't have PageUp/PageDn/Home/End and Ins/Del keys ready as you have with DEC VT220 or better. Unfortunately terminal emulation coming with Microsoft Windows 95/98/NT can emulate DEC VT100, only.
With a proper terminal emulation you will be free to move your cursor using cursor keys. If you have a DEC VT220 or better you can also switch between Replace and Insert by hitting the Ins key on your keyboard without exiting Edit Mode. To exit Edit Mode back to Movement Mode, press the Esc key. Some terminal emulations will not let you do this by simply pressing Esc. Consult your terminal emulation users guide if Esc does not work. Esc may be moved to a different key.
In Edit Mode just type text like in any other text editor. You can remove what you just typed pressing BS. On some terminal emulations you can also delete characters by pressing Del on your keyboard and your cursor can be moved page wise etc. Using DEC VT100 you will have to exit Edit Mode, use x for delete and reenter Edit Mode by pressing i again. Not very comfortable. Use DEC VT220 or better if you can.
There normally is some online help: man vi. There is also a number of usable books such as this one: