Emacs Quick Guide
Emacs is a very powerful text editor which you can use to create or edit text files in UNIX. To start Emacs, type emacs at the UNIX $ prompt. Editing commands are issued by first pressing the Escape key (shown below as M) followed by a command character or by holding down the Control key (shown below as C) and typing a command character.
Emacs 20.7, the version available on the CUNIX Cluster, has X-windows (graphics) support: when run in an X environment, such as on a ColumbiaNet Station or an HP workstation (251 Mudd), and the DISPLAY variable is set correctly, Emacs is displayed in a separate window with a pull-down menu on the top and full mouse control.
If you are using Emacs outside an X environment and want to remove the pull-down menu for the current session, type Esc-X menu-bar-mode. To permanently remove this option, include the following line in the .emacs init file found in your home directory:
(menu-bar-mode nil)
See the man page ($ man emacs) for more information on using Emacs.
- Glossary
- C-
- A control character. C-f means hold down the key marked Control or CTRL and then type f
- Glossary
- C-A control character. C-f means hold down the key marked Control or CTRL and then type f M-
- A two-character command sequence where the first is the key marked ESC. M-f means press ESC, then f.
- Glossary
- M-x string
- A command obtained by typing in its name. M-x revert-buffer means type ESC then xthen revert-buffer then press the Enter or Return key.
- Glossary
- point
- Emacs term for cursor position in current buffer
- Glossary
- mark
- An invisible text marker in the file
- Help and Information Functions
- C-h t
- Display the Emacs tutorial (for novices)
- Help and Information Functions
- C-h i
- Enter Info, the internal documentation browser
- Help and Information Functions
- C-g
- Abort the current command (quit)
- Help and Information Functions
- C-h m
- Describe special Emacs commands that are currently available
- Help and Information Functions
- C-h k
- Describe a particular command (for example, C-h k C-a describes the C-acommand)
- Help and Information Functions
- C-h l
- Show the last 60 characters and commands typed
- Help and Information Functions
- C-_
- Undo effect of the last change/command (can be repeated)
- Help and Information Functions
- C-h a string
- Show all commands containing string in their name
- Help and Information Functions
- M-n
- Used before a command, repeats it n times (same as C-u n)
- Help and Information Functions
- C-q
- Insert special characters (for example, typing C-q C-l inserts C-l)
- Help and Information Functions
- C-x d
- Display and edit directory lists (C-h m shows commands)
- Getting out
- C-x C-s
- Write this buffer to disk (overwrites old file contents)
- Getting out
- C-x C-w string
- Write this buffer to a disk file with specified name
- Getting out
- C-x C-z
- Exit to the shell (can be continued later)
- Getting out
- C-x C-c
- Exit and kill this Emacs (cannot be continued later)
- Getting out
- M-x shell
- Start up a UNIX shell in its own buffer
- Buffer Operations
- Buffer Operations
- C-x C-f file
- Get or create file named file in buffer of same name
- Buffer Operations
- C-x b file
- Select existing buffer named file for editing
- Buffer Operations
- C-x k file
- Delete buffer named file
- Buffer Operations
- C-x C-b
- Display the list of available buffers
- Buffer Operations
- M-<
- Move to the top of the current buffer/file
- Buffer Operations
- M->
- Move to the end of the current buffer/file
- Character Operations
- C-b
- Move point one character to the left (backward)
- Character Operations
- C-f
- Move point one character to the right (forward)
- Character Operations
- C-p
- Move point up one line (previous line)
- Character Operations
- C-n
- Move point down one line (next line)
- Character Operations
- DELETE
- Delete character to the left of point (also marked RUBOUT)
- Character Operations
- C-d
- Delete character to the right of (or under) point
- Character Operations
- C-t
- Transpose two characters around point (for example, htbecomes th)
- Word Operations
- Word Operations
- M-b
- Move point one word to the left (backward word)
- Word Operations
- M-f
- Move point one word to the right (forward word)
- Word Operations
- M-DELETE
- Delete one word to the left (C-y yanks it back at point)
- Word Operations
- M-d
- Delete one word to the right (C-y yanks it back at point)
- Word Operations
- M-t
- Reverse words around point (for example, if only becomes only if)
- Line Operations
- C-a
- Move point to the beginning of this line
- Line Operations
- C-e
- Move point to the end of this line
- Line Operations
- C-o
- Open up blank line at point
- Line Operations
- C-x C-o
- Close up all blank lines above and below point
- Line Operations
- C-k
- Delete from point to end of line (C-y yanks it back)
- Line Operations
- M-0 C-k
- Delete from beginning of line to point (C-y yanks it back )
- Sentence Operations
- M-a
- Move point to the beginning of this sentence
- Sentence Operations
- M-e
- Move point to the end of this sentence
- Sentence Operations
- C-x DELETE
- Delete beginning of sentence to point (C-y yanks it back)
- Sentence Operations
- M-k
- Delete from point to end of sentence (C-y yanks it back)
- Paragraph Operations
- M-{
- Move point to beginning of this paragraph
- Paragraph Operations
- M-}
- Move point to end of this paragraph
- Paragraph Operations
- M-q
- Fill this paragraph
- Paragraph Operations
- M-1 M-q
- Justify this paragraph
- Paragraph Operations
- M-n C-x f
- Set fill column to n(for example, M-60 C-x f sets it to 60)
- Screen Operations
- C-v
- Move to next screen of text (screens overlap by one line)
- Screen Operations
- M-v
- Move to previous screen (overlaps by one line)
- Screen Operations
- C-l
- Redisplay current screen and center point
- Page Operations
- C-x [
- Move to beginning of this page (previous C-lcharacter)
- Page Operations
- C-x ]
- Move to end of current page (next C-lcharacter)
- Search and Replace
- C-s string
- Search forward for string, one character at a time
- Search and Replace
- C-r string
- Search backward for string, one character at a time
- Search and Replace
- M-x replace-string string1 string2
- Replace string1 with string2(prompts for strings)
- Search and Replace
- M-x query-replace string1 string2
- Optionally replace string1 with string2, but confirms each
- Region Operations
- C-@
- Set the mark
- Region Operations
- C-x C-x
- Exchange point and mark (move to other end of region)
- Region Operations
- C-w
- Delete region (C-y yanks it back)
- Region Operations
- C-y
- Yank back the last deleted text at point
- Window Operations
- C-x 2
- Split screen into two windows (same buffer in each)
- Window Operations
- C-x 1
- Make this window the only one (delete all others)
- Window Operations
- C-x o
- Move to other window on screen
- Window Operations
- ESC C-v
- Display the next screen in the other window