16.3 Opening Files

vi allows you to open files from command mode as well as specifying a file on the command line to open. To open the file /etc/lilo.conf:

:e /etc/lilo.conf

If you have made changes to the current buffer without saving, vi will complain. You can still open the file without saving the current buffer by typing :e!, followed by a space and the filename. In general, vi's warnings can be suppressed by following the command with an exclamation mark.

If you want to reopen the current file, you can do so simply by typing e!. This is particularly useful if you have somehow messed up the file and want to reopen it.

Some vi clones (for example, vim) allow for multiple buffers to be open at the same time. For example, to open up the file 09-vi.sgml in my home directory while another file was open, I would type:

:split ~/09-vi.sgml

The new file is displayed on the top half of the screen, and the old file is displayed in the bottom half of the screen. There are a lot of commands that manipulate the split screen, and many of these commands start to resemble something out of Emacs The best place to look up these commands would be the man page for your vi clone. Note that many clones do not support the split-screen idea, so you might not be able to use it at all.