Emacs can work on more than one file at a time. In fact, the only limit on how many buffers your Emacs can contain is the actual amount of memory available on the machine. The command to bring a new file into an Emacs buffer is C-x C-f. When you type it, you will be prompted for a filename in the minibuffer:
The syntax here is the same one used to specify files from the
shell prompt; slashes represent subdirectories, ~
means your
home directory. You also get filename completion, meaning
that if you've typed enough of a filename at the prompt to identify
the file uniquely, you can just hit to complete it (or to
show possible completions, if there are more than one).
also has a role in filename completion in the minibuffer, similar to
, but I'll let you experiment to find out how the two differ.
Once you have the full filename in the minibuffer, hit
,
and Emacs will bring up a buffer displaying that file. In Emacs, this
process is known as finding a file. Go ahead and find some
other unimportant text file now, and bring it into Emacs (do this from
our original buffer some_file.txt). Now you have a new buffer;
I'll pretend it's called another_file.txt, since I can't see
your mode line.
Your original buffer seems to have disappeared--you're
probably wondering where it went. It's still inside Emacs, and you
can switch back to it with C-x b. When you type this, you will
see that the minibuffer prompts you for a buffer to switch to, and it
names a default. The default is the buffer you'd get if you just hit
at the prompt, without typing a buffer name. The default
buffer to switch to is always the one most recently left, so that when
you are doing a lot of work between two buffers, C-x b always
defaults to the ``other'' buffer (which saves you from having to type
the buffer name). Even if the default buffer is the one you want,
however, you should try typing in its name anyway.
Notice that you get the same sort of completion you got when
finding a file: hitting completes as much of a buffer name
as it can, and so on. Whenever you are being prompted for something
in the minibuffer, it's a good idea to see if Emacs is doing
completion. Taking advantage of completion whenever it's offered will
save you a lot of typing. Emacs usually does completion when you are
choosing one item out of some predefined list.
Everything you learned about moving around and editing text in the
first buffer applies to the new one. Go ahead and change some text in
the new buffer, but don't save it (i.e. don't type C-x C-s).
Let's assume that you want to discard your changes without saving them
in the file. The command for that is C-x k, which ``kills'' the
buffer. Type it now. First you will be asked which buffer to kill,
but the default is the current buffer, and that's almost always the
one you want to kill, so just hit . Then you will be
asked if you really want to kill the buffer--Emacs always
checks before killing a buffer that has unsaved changes in it. Just
type ``yes'' and hit
, if you want to kill it.
Go ahead and practice loading in files, modifying them, saving
them, and killing their buffers. Make sure you don't modify any
important system files in a way that will cause trouble, of course, but
do try to have at least five buffers open at once, so you can get the
hang of switching between them.