
Emacs
Introduction
Emacs is a powerful text editor available on the Unix system. There are numerous variants of the Emacs editor; the version available on our Unix system is called GNU Emacs.
To invoke the Emacs editor, type emacs filename (substituting your actual file name for "filename")
The Emacs Screen
The Emacs screen consists of three parts (listed from the bottom up):
|
Part Name |
Location |
Description |
|
echo area |
Bottom line |
The echo area displays feedback to the user on the editing process. |
|
mode line |
Above echo area |
The mode line contains status information on the text currently loaded in the text window (the current buffer) |
|
Text window |
Above mode line |
Displays the current text loaded from a file or manual entered by a user. |
Moving Around in Emacs
As you type, the cursor always stays in front of (that is, to the right of) each letter that appears. The cursor points to your current position on the screen. Knowing the location of the cursor is important because any text you type will be entered at the position of the cursor, and any of the editing commands you perform are executed at the position of the cursor.
The following table contains several useful key commands for navigating and issuing special commands in Emacs. (Most terminal emulators allow use of the arrow keys for moving the cursor.)
|
Keyboard Cursor Control |
Useful Key Commands |
||
|
CTRL-p |
Previous line |
CTRL-x CTRL-s |
Save your file |
|
CTRL-n |
Next line |
CTRL-x CTRL-c |
Exit emacs |
|
CTRL-f |
Forward one character |
CTRL-l |
Redraw screen |
|
CTRL-b |
Backward one character |
CTRL-g |
Abort command |
|
META-f |
Forward one word |
CTRL-x I |
Insert a file |
|
META-b |
Backward one word |
DELETE |
Deletes character to left of cursor (if keys are mapped properly) |
|
CTRL-a |
Beginning of line |
CTRL –d |
Deletes character to right of cursor |
|
CTRL-e |
End of line |
META-DELETE |
Kills back to beginning of a word |
|
META-a |
Beginning of sentence |
META-d |
Kills up to the end of a word |
|
META-e |
End of sentence |
CTRL-k |
Kills to the end of a line |
|
CTRL-v |
Move forward one screen |
META-k |
Kills to the end of current sentence |
|
META-v |
Move backward one screen |
CTRL-y |
Yanks back most recent killed item |
|
META-y |
Cycles through stored killed items |
||
|
CTRL-x u |
Reverse most recent editing change |
||
** Note: Most ordinary keyboards do not have a "meta" key. Use the ESC key instead. M-x or META-x means press the ESC key, release it, and press the "x" key. **
Exiting Emacs
Before leaving Emacs, you may save your file with CTRL-x followed by CTRL-s. Then you may exit -- the usual way to do so is to use the command CTRL-x followed by CTRL-c. Before terminating, Emacs checks for any buffers that you have changed but not saved. If one is found, you are asked if you wish to leave Emacs without saving the buffer to a file.
Emacs Help
Emacs has an online tutorial. You call the tutorial from within Emacs by typing CTRL-h followed by t. The beginning of the tutorial introduces you to the basics of cursor movement, screen editing, and the Emacs windowed environment. Later, more advanced topics such as major and minor modes, searching, and finding more help are covered.
Emacs' on-line help is accessed by typing CTRL-h. After pressing CTRL-h, follow the directions given in the echo area to select what you want help on. For example, for help on how to use help, type CTRL-h followed by "?" and then another CTRL-h. (This tells Emacs that you want help and then tells help that you want help on the subject help.) If you don't know what to type next in "help," look first in the echo area for directions. If there are no directions, try typing a question mark.
Information Technology Services Helpdesk, LC-27
(518) 442-3700
Submit a Help Desk Request at:
http://www.albany.edu/its/help/help-request.html