Sunday, March 8, 2009

Emacs Example Tutorial: exit emacs and save a file or discard changes

For those who are just starting to learn emacs, the key command sequence to save a file is:

Ctrl x s

That means hold down the Control key, tap the x key once, and the s key once, let go of Control key. If you're used to using "Cntl+s" in a graphical progam to save file, this key binding might seem a little awkward at first but you'll get used to it quickly.

You can also choose whether or not to save by simply exiting emacs and telling it "y" for "yes" or "n" for "no" when it asks you if you want to save your changes (also known as "Exit saving changes") by typing the "quit" key command sequence:

Ctrl x c

Emacs will then prompt you "Save file /path/to/filename? (y, n, !, ., q, C-r or C-h)" which means you must answer with one of the options listed inthe parenthesis. To save just tap the "y" key and you're done.

If you decide you don't want to save your changes, tap "n" for "no". Emacs will then double-check your decision by asking you:

Modified buffers exist; exit anyway? (yes or no)

Type "yes", which in this context means "yes I really do want to exit and discard my changes"
If you type "no" emacs will send you back to editing mode with Emacs still open and your unsaved changes still visible and accessable in the window.

No comments: