17.5 Saving Files

In order to save a file, you type

C-x C-s

Emacs will not ask you for a filename, the buffer will just be saved to the file it was loaded from. If you want to save your text to another file, type

C-x C-w

When you save the file for the first time in this session, Emacs will normally save the old version of your file to a backup file, which has the same name appended with a tilde: so if you're editing a file “cars.txt”, Emacs will create a backup “cars.txt~”.

This backup file is a copy of the file that you opened. While you are working, Emacs will also regularly create an auto-save copy of the work you are doing, to a file named with hash signs: #cars.txt#. This backup is deleted when you save the file with C-x C-s.

When you are done editing a file, you can kill the buffer that holds it by typing

C-x k

Emacs will then ask you which buffer you want to kill, with the current buffer as default, which you can select by hitting ENTER. If you haven't saved your file yet, Emacs will ask you if you really want to kill the buffer.

17.5.1 Quitting Emacs

When you are done with Emacs altogether, you can type

C-x C-c

This quits Emacs. If you have any unsaved files, Emacs will tell you so, and ask if you want to save them each in turn. If you answer no to any of these, Emacs will ask for one final confirmation and then quit.