Opening and Closing Files
You can use vi to edit any text file. vi copies the file to be edited into a buffer (an area temporarily set aside in memory), displays the buffer (though you can see only one screenful at a time), and lets you add, delete, and change text. When you save your edits, vi copies the edited buffer back into a permanent file, replacing the old file of the same name. Remember that you are always working on acopy of your file in the buffer, and that your edits will not affect your original file until you save the buffer. Saving your edits is also called “writing the buffer,” or more commonly, “writing your file.”
Opening a File
![]()
![]()
vi is the Unix
command that invokes the vi
editor for an existing file or for a brand new file. The syntax for
the vi command is:
$vi[filename]
The brackets shown on the above command line indicate that the
filename is optional. The brackets should not be typed. The $ is the Unix prompt. If the filename is
omitted, vi will open an unnamed
buffer. You can assign the name when you write the buffer into a
file. For right now, though, let’s stick to naming the file on the
command line.
A filename must be unique inside its directory. A filename can include any 8-bit character except a slash (/), which is reserved as the separator between files and ...