Opening a File

You can open a file by specifying the filename when you start Emacs (as we did earlier) or by typing C-x C-f (the long command name for this is find-file). C-x C-f creates a new buffer that has the same name as the file.

Type: C-x C-f

Opening a File

Emacs prompts you for a filename; respond by typing the filename, followed by RETURN.

Type: newfile RETURN

Opening a File

Emacs starts another buffer with the new file in it.

To type C-x C-f, hold down CTRL, press x and then press f. Now release CTRL. This procedure may sound complicated, but after you try it a few times it’s easy.

After you type C-x C-f, Emacs uses the minibuffer to ask you for the filename. Remember that whenever Emacs wants information from you, it automatically puts the cursor in the minibuffer. When you’re done typing in the minibuffer, you need to press RETURN to enter the command. You don’t need a RETURN after normal editing commands (i.e., commands that use the CTRL or ESC keys).

What if you try to read the same file twice? Instead of creating a new buffer, Emacs just moves you to the buffer the file is in.

Now is a good time to try typing if you haven’t already done so. You may find yourself wanting to learn more about cursor movement and editing; that’s fine. Feel free to skim the rest of this chapter and go on to Chapter 2. We ...

Get Learning GNU Emacs, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.