Emacs is a powerful text editor in UNIX. From within Emacs it is possible to compile programs, read news, read mail, and execute UNIX commands, making it practically an operating system of its own. As with any program that seems to be able to do everything, Emacs contains some rather obscure control commands to get things done more quickly. In order to quickly find any utility in Emacs, it is necessary to do some memorization. Users who wish to avoid this should use another text editor, like Pico, that is easier to use but does less than Emacs.
Emacs is invoked at the UNIX prompt by typing
If the file exists, its contents are placed in the resulting Emacs screen. If the file does not exist, a blank screen appears and a file is created
as soon as information is typed on the screen.
Note: If you are using an X-Windows environment (a sun desktop, X-win32 on the PC, or X11 on a Mac), you can return to the
command prompt after starting emacs by typing
Understanding Buffers, Marks and Points
Emacs uses what are called buffers to store the data. Several buffers can be in operation at once, and any number can be displayed on the screen at one time, but the beginning Emacs user will probably limit himself to using one buffer at a time. The point is defined as where cursor is presently located in the current buffer. A mark can be set so that the point can be placed elsewhere in the buffer. The area between the mark and the point is known as the region. Operations can be applied to regions (e.g. spell check, copy, deletion, etc.) or to an entire buffer.
Moving Around in an Emacs Buffer
In most situations, moving the point (cursor) around in the buffer is as simple as using the arrow keys. However, there are alternate keys available for those who cannot or would rather not use the arrow keys. Most of the control key combinations are designed to be memorable, but the beginning user often finds them non-intuitive. Examples are <Control>-b for backward movement, <Control>-f for forward movement, <Control>-p to move to the previous line, and <Control>-n to move to the next line. A more comprehensive list of keystrokes is given in the Quick Reference section given earlier.
Saving Your Work
By default, Emacs automatically saves your work at regular intervals. Auto-saved files are named
#filename#, to distinguish them from regularly-saved files. When you save a file, emacs also saves an
unmodified version as
filename~. At any time during an Emacs session, you can force Emacs to perform a
save with the key combination <Control>-x <Control>-s (for save). You can easily tell if the
current buffer contains unsaved changes if
** appears before Emacs on the bottom of the screen. As with
any text editor, frequent saves are recommended.
Cancelling the Current Operation
You will occasionally start a command (such as Help) which you do not want to continue. The keystroke <Control>-g will cancel the current command. <ESC>-<ESC>-<ESC> will similarly exit certain functions.
When you wish to leave Emacs, you can do this with the key combination <Control>-x <Control>-c. If
your buffer contains unsaved changes, you will be asked if you wish to save them. Type
n. If you choose
n, changes since the last save are not kept, and
#filename# file is created.
Emacs has extensive on-line help. It can be accessed by typing <Control>-h. It is helpful to go through the interactive tutorial in <Control>-h t.
February 04, 2011