Emacs
is an extensible, customizable, self-documenting real-time display editor.
It was first designed for UNIX, but
for Win* and Mac as well (see the above front page for Emacs).
Since it is "programmable" (in a version of Lisp), it is
being continuously extended to provide support for editing different types
of files (HTML, TeX, C++, shell-scripting, Perl, etc.). It can also handle
mail, news, spell-checking, etc. It provides interfaces for many UNIX
commands as well (to mention only one: a convenient way to compare two
files, based on diff
). Most of these add-ons come as separate
packages (which are plain-text files), that are loaded when needed.
GNU Emacs is "free software"; this means that everyone is free to use it and free to redistribute it on certain conditions (for details, check the help menu within Emacs).
To invoke it, type emacs &
in a shell.
If you do not want Emacs to run in a separate window, type
instead emacs -nw
("nw" stands for "no
window"). In this case you will have no mouse support (but can still
use the menus; see below), and might have a problem with CONTROL-s
(see the
"Note" in the part about "Searching").
Originally Emacs actions (e.g., save file) were accessible through various
key combinations. By now, you can do quite a bit using only the mouse.
However, using a key combination is quicker than "aiming and
clicking" the mouse.
NOTE: if, e.g., you are invoking Emacs on a remote machine, the
mouse might not be usable. You can reach the menus by
the sequence M-`
(note that `
is the less
frequently used quotation mark, the opposite of '
). See below
what M-
means.
Emacs comes with an incorporated help (see some of its items on the
starting screen) and manual.
To reach the help, type CONTROL-h
and follow the
instructions (in the bottom line of the screen).
To read the manual (as well as the manual of other applications), type
C-h i
. Or, use the mouse to open the "Help" menu.
Then follow the instructions at the top of the page.
The help includes a tutorial. You can reach it directly by typing
C-h t
.
NOTE: In Emacs parlance, e.g., C-x
means
CONTROL-x
, while M-x
means META-x
;
you have to press and hold the CONTROL
or
META
key, and then press x
.
The META
key is sometimes labelled ALT
. If
you do not have it, press ESCAPE
instead, followed
by, say, x
.
In any Emacs buffer (e.g., in the manual or tutorial), you can
search forward with C-s
and backward with C-r
.
Watch both the dialog box (at the bottom of the screen) and the buffer in
which you started the search!
To reach the next occurrence or change direction, repeat
C-s
or C-r
. To cancel the search press
C-g
. To stop at a hit, press RETURN
. To search
again for the same sequence, type C-s
or C-r
twice.
JUST IN CASE:
C-g
.
ESC ESC
ESC
. That is an all-purpose "get out" command. You can
also use it for eliminating extra windows, and getting out of the
minibuffer (i.e., the dialog box).
C-g
to get out of a recursive editing
level. This is because C-g
is used for canceling commands and
arguments WITHIN the recursive editing level.
C-_
and C-/
.
C-x C-c
, or looking
into the "File" menu. If there are unsaved buffers, you will be
asked to take care of them.
This is the part of the tutorial that explains
searching, and lets you practice as well (however, for that you should be
reading it in Emacs - do C-h t
and advance quite a few pages).
* SEARCHING ----------- Emacs can do searches for strings (these are groups of contiguous characters or words) either forward through the text or backward through it. Searching for a string is a cursor motion command; it moves the cursor to the next place where that string appears. The Emacs search command is different from the search commands of most editors, in that it is "incremental". This means that the search happens while you type in the string to search for. The command to initiate a search is C-s for forward search, and C-r for reverse search. BUT WAIT! Don't try them now. When you type C-s you'll notice that the string "I-search" appears as a prompt in the echo area. This tells you that Emacs is in what is called an incremental search waiting for you to type the thing that you want to search for. <Return> terminates a search. >> Now type C-s to start a search. SLOWLY, one letter at a time, type the word 'cursor', pausing after you type each character to notice what happens to the cursor. Now you have searched for "cursor", once. >> Type C-s again, to search for the next occurrence of "cursor". >> Now type <Delete> four times and see how the cursor moves. >> Type <Return> to terminate the search. Did you see what happened? Emacs, in an incremental search, tries to go to the occurrence of the string that you've typed out so far. To go to the next occurrence of 'cursor' just type C-s again. If no such occurrence exists, Emacs beeps and tells you the search is currently "failing". C-g would also terminate the search. NOTE: On some systems, typing C-s will freeze the screen and you will see no further output from Emacs. This indicates that an operating system "feature" called "flow control" is intercepting the C-s and not letting it get through to Emacs. To unfreeze the screen, type C-q. Then see the section "Spontaneous Entry to Incremental Search" in the Emacs manual for advice on dealing with this "feature". If you are in the middle of an incremental search and type <Delete>, you'll notice that the last character in the search string is erased and the search backs up to the last place of the search. For instance, suppose you have typed "c", to search for the first occurrence of "c". Now if you type "u", the cursor will move to the first occurrence of "cu". Now type <Delete>. This erases the "u" from the search string, and the cursor moves back to the first occurrence of "c". If you are in the middle of a search and type a control or meta character (with a few exceptions--characters that are special in a search, such as C-s and C-r), the search is terminated. The C-s starts a search that looks for any occurrence of the search string AFTER the current cursor position. If you want to search for something earlier in the text, type C-r instead. Everything that we have said about C-s also applies to C-r, except that the direction of the search is reversed.