Minimal EMACS Commands


To get into the text editor EMACS from the operating system, type emacs fname . If fname is a previously existing file, it will be brought into EMACS and you will see it on the screen. If fname does not already exist, it will be created. Whatever you type will be inserted to the left of the blinking cursor. Pressing the DELETE or the BACKSPACE key will erase the character to the left of the cursor. Move around with the arrows.

EMACS is largely controlled by sequences single keystroke commands. To let EMACS know that a sequence is meant to be a command and not something to be inserted into the text, you must either hold down the CONTROL key and press the command key, or strike the ESC (escape) key first and then press the command key.
In this handout, C- and then a letter means hold down the CONTROL key and press the letter. ESC- and then a letter means strike the ESC key and then press the letter. Here is a very small set of useful commands:

C-x C-c Exit EMACS, saving the file. Really want to? Reply y for yes or n for no.
C-x C-s Saves the file you are working on.
C-g Makes emacs stop whatever it is trying to do, like prompting you with several choices you are not interested in. This is how you back out of a command you wish you had not entered.
C-z Temorarily suspends emacs, escaping to the operating system prompt. Come back with fg.
C-x C-w Save the file under a new name. You are prompted for the new name.
C-e Move cursor to end of line.
C-a Move cursor to beginning of line.
C-v Forward a screen.
ESC-v Backward a screen.
ESC-> Move to end of file.
ESC-< Move to beginning of file.
C-k Kill (delete) to end of line; contents are saved in the "kill" buffer.
C-@ Set "mark". (Now move "point" (cursor) to other boundary of text you want to copy or cut.)
C-w Cuts text between point and mark, placing it in kill buffer.
ESC-w Copies text between point and mark, placing it in kill buffer.
C-y "Yank" (paste) contents of kill buffer. If several items have been deleted consecutively, (like with many C-K's) they're all there.
C-x i Insert file at cursor. EMACS will ask for file name.
ESC-% Search & replace. y=yes, n=no, !=yes from here on with no prompt, ESC terminates the search.
C-x u Undo the last command. Keep doing it to keep undoing.

There is a lot more to emacs than this. A tutorial is accessible by typing C-h t . The entire emacs manual is available on line (!) under info, using C-h i.


This handout is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.