9.1.1 Open a document and check its identity

  1. Press C-x C-f. At the file prompt, choose the existing text file you want to read. Complete or type its path, then press RET. Emacs selects the file’s buffer; use C-e m to hear its name and mode.
  2. Press M-<, then C-e l to read its first line. Check that the content is what you expected before editing. A missing filename can instead open an empty buffer for a new file. Opening that buffer alone has not created a saved document: check the name rather than assuming your text was lost.
  3. If you need to confirm the full destination, use C-h v buffer-file-name RET. This Help shows the pathname visited by the source buffer; nil means that buffer is not visiting a file. Read Help as described in Using Online Help, then return to the document by its buffer name with C-x b. Do not edit while Help is selected.

For reading without accidental text edits, use C-x C-r in place of C-x C-f. That opens the file read-only. A read-only buffer is different from a document with unsaved changes; do not remove the protection merely to make an unfamiliar command work.

When you follow this task from Info or HTML, leave the manual available and switch to the document before trying its editing commands. In Emacs, C-x b selects an existing buffer by name; C-x C-f selects a file by its path. Those are different questions even when the buffer and file have similar names.

To close a document buffer, use C-x k and check the name and any unsaved-work prompt. That is not a file deletion. Unlike a Dired or Help buffer, an ordinary text buffer does not use q to quit: typing it normally inserts a letter.