Now that the terminal type is (hopefully) correctly set, you are ready to get startedwith VI.
Starting the VI Editor
The VI editor lets a user create new files or edit existing files. The command to startthe VI editor is
, followed by the filename. For example, to edit a file called
, you would type
and then return. You can start VI without afilename, but when you want to save your work, you will have to tell VI whichfilename to save it into later.When you start VI for the first time, you will see a screen filled with tildes (A tildelooks like this: ~) on the left side of the screen. Any blank lines beyond the end of thefile are shown this way. At the bottom of your screen, the filename should be shown,if you specified an existing file, and the size of the file will be shown as well, likethis:
"filename" 21 lines, 385 characters
If the file you specified does not exist, then it will tell you that it is a new file, like this:
"newfile" [New file]
If you started VI without a filename, the bottom line of the screen will just be blank when VIstarts. If the screen does not show you these expected results, your terminal type may be setwrong. Just type
Getting Out of VI
Now that you know how to get into VI, it would be a good idea to know how to get outof it. The VI editor hastwo modes and in order to get out of VI, you have to be in
mode. Hit the key labeled "
" or "
" (If your terminal does not havesuch a key, then try ^[, or control-[.) to get into
mode. If you were alreadyin the command mode when you hit "
", don't worry. It might beep, but you willstill be in the
mode.The command to quit out of VI is
. Once in
mode, type colon, and 'q',followed by return. If your file has been modified in any way, the editor will warn youof this, and not let you quit. To ignore this message, the command to quit out of VIwithout saving is
. This lets you exit VI without saving any of the changes.Of course, normally in an editor, you would want to save the changes you have made.The command to save the contents of the editor is
. You can combine the abovecommand with the quit command, or
. You can specify a different file name tosave to by specifying the name after the
. For example, if you wanted to save thefile you were working as another filename called
, you would type: