There is also a short appendix which gives the special meaning each command character has in vi.
The quick reference card summarizes the commands of vi in a very compact format. You should have the card handy while you are learning vi.
Code Full name Type _____________________________________________________ 2621 Hewlett-Packard 2621A/P Intelligent 2645 Hewlett-Packard 264x Intelligent act4 Microterm ACT-IV Dumb act5 Microterm ACT-V Dumb adm3a Lear Siegler ADM-3a Dumb c100 Human Design Concept 100 Intelligent dm1520 Datamedia 1520 Dumb dm2500 Datamedia 2500 Intelligent dm3025 Datamedia 3025 Intelligent fox Perkin-Elmer Fox Dumb h1500 Hazeltine 1500 Intelligent h19 Heathkit h19 Intelligent i100 Infoton 100 Intelligent mime Imitating a smart act4 Intelligent t1061 Teleray 1061 Intelligent vt52 Dec VT-52 Dumb vt100 DEC VT-100 xterm MIT X11 terminal window
suppose for example that you have a hewlett-packard hp2621a terminal. the code used by the system for this terminal is `2621'. in this case you can use one of the following commands to tell the system the type of your terminal:
% setenv TERM 2621This command works with the csh shell. If you are using the standard Bourne shell sh or K shell ksh then give the commands
$ TERM=2621 $ export TERMIf you want to arrange to have your terminal type set up automatically when you log in, you can use the tset program. If you dial in on a mime, but often use hardwired ports, a typical line for your .login file (if you use csh) would be
setenv TERM `tset - -d mime`or for your .profile file (if you use sh)
TERM=`tset - -d mime`Tset knows which terminals are hardwired to each port and needs only to be told that when you dial in you are probably on a mime. Tset is usually used to change the erase and kill characters, too.
% vi namereplacing name with the name of the copy file you just created. The screen should clear and the text of your file should appear on the screen.
If something else happens:
If you gave the system an incorrect terminal type code then the editor may have just made a mess out of your screen. This happens when it sends control codes for one kind of terminal to some other kind of terminal. In this case hit the keys :q (colon and the q key) and then hit the RETURN key. This should get you back to the command level interpreter. Figure out what you did wrong (ask someone else if necessary) and try again.
Another thing which can go wrong is that you typed the wrong file name and the editor just printed an error diagnostic. In this case you should follow the above procedure for getting out of the editor, and try again this time spelling the file name correctly.
If the editor doesn't seem to respond to the commands which you type here, try sending an interrupt to it by hitting the DEL or RUB key on your terminal, and then hitting the :q command again followed by a carriage return.
(Particular note for the HP2621: on this terminal the function keys must be shifted (ick) to send to the machine, otherwise they only act locally. Unshifted use will leave the cursor positioned incorrectly.)
The CR or RETURN key is important because it is used to terminate certain commands. It is usually at the right side of the keyboard, and is the same command used at the end of each shell command.
Another very useful key is the DEL or RUB key, which generates an interrupt, telling the editor to stop what it is doing. It is a forceful way of making the editor listen to you, or to return it to the quiescent state if you don't know or don't like what is going on. Try hitting the `/' key on your terminal. This key is used when you want to specify a string to be searched for. The cursor should now be positioned at the bottom line of the terminal after a `/' printed as a prompt. You can get the cursor back to the current position by hitting the DEL or RUB key; try this now. (Backspacing over the `/' will also cancel the search). From now on we will simply refer to hitting the DEL or RUB key as ``sending an interrupt.'' (On some systems, this interruptibility comes at a price: you cannot type ahead when the editor is computing with the cursor on the bottom line).
The editor often echoes your commands on the last line of the terminal. If the cursor is on the first position of this last line, then the editor is performing a computation, such as computing a new position in the file after a search or running a command to reformat part of the buffer. When this is happening you can stop the editor by sending an interrupt.
:q![CR]Where [CR] represents the carriage return key. (All commands which read from the last display line can also be terminated with a ESC as well as an [CR]). :q! is a dangerous but occasionally essential command which ends the editor session and discards all your changes. You need to know about this command in case you change the editor's copy of a file you wish only to look at. Be very careful not to give this command when you really want to save the changes you have made.