Entering and exiting the vi editor

You invoke the vi editor by typing "vi filename". If the file exists, "vi" will display the first few lines of the file and give some status information about the file on the status line (the last line on the screen). If the file does not exist you will see something like this: ~ ~ ~ ~ ~ ~ "letter.tex" [New file] "vi" uses the the bottom line (the 24th line of most terminals) as its status line. It will display error messages, information on search strings, and various other informational messages on this line.

At the beginning of an editing session, "vi" makes a copy of your file and places it into a work buffer. All the changes and additions you enter will be added to the work buffer and not to the original file. If you are satisfied with the changes you have made, you can exit using the following command from command mode.

Command mode is entered by pressing the [ESC] key. If you are already in command mode, your terminal will beep at you. Don't worry, no harm will be done if this happens.

If you have made some drastic errors, you can exit from the editor without saving any of the changes. The command to do this is

which is entered at command mode.

Click here to go to the next section.

Or click here to go to the top of the chapter.