Knowing how to get out, and how to ask for help, makes Emacs much less intimidating. C- means Ctrl and M- means Alt (Meta).
Exiting
Press C-x C-c. If a file buffer has unsaved changes, Emacs asks whether to save it. Answer y to save or n to leave it unsaved.
If you answer n, Emacs warns you and asks for confirmation:
Modified buffers exist; exit anyway? (yes or no)Here you type the full word yes or no. The exact prompts can vary a little between versions and settings.
Suspending is not exiting
In a terminal, C-z suspends Emacs and returns you to the shell. Emacs is still there, with your unsaved work. Bring it back with:
$ jobs
[1]+ Stopped emacs -nw notes.txt
$ fgIf you press C-z by accident and start emacs again, you end up with two copies.
Cancelling
C-g cancels a half-typed command or a prompt. It does not exit the editor.
The help system
All help commands start with C-h:
C-h topens the tutorial.C-h kthen a key: describes what that key does.C-h fdescribes a function (command).C-h vdescribes a variable.C-h asearches for commands matching a word.C-h blists the key bindings in effect.C-h mdescribes the current modes.
For example, press C-h k and then C-x C-s. A help window explains that the keys run save-buffer.
If you remember a topic but no command name, use C-h a and type a word such as replace.
Closing the help window
Help often opens in a second window. Press C-x 1 to keep only the window you are in. If you moved into the help window, pressing q closes it.
Some terminals send the same code for Backspace and C-h. If a help key misbehaves, press F1 instead, as in F1 k.
Outside the editor
The shell command man emacs describes the startup options, and the GNU Emacs manual covers everything else. Inside Emacs, C-h r opens that manual if your distribution installed it. Some package it separately.
Try it
- Start
emacs -nw notes.txt. - Press
C-h k, thenC-a, and read the description. - Press
C-x 1to close the help window. - Press
C-h a, typekill, and pressEnter. - Type some text, press
C-z, runjobs, thenfg. - Press
C-x C-cand answer the save question.
For a live Linux shell, there is the processes and cron lab.
Check your understanding
Emacs Exiting and Help
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.