home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
gnu
/
emacs-18.59-bin.lha
/
lib
/
emacs
/
18.59
/
etc
/
TUTORIAL
< prev
next >
Wrap
Text File
|
1988-05-19
|
34KB
|
805 lines
Copyright (c) 1985 Free Software Foundation, Inc; See end for conditions.
You are looking at the Emacs tutorial.
Emacs commands generally involve the CONTROL key (sometimes labelled
CTRL or CTL) or the META key (sometimes labelled EDIT). Rather than
write out META or CONTROL each time we want you to prefix a character,
we'll use the following abbreviations:
C-<chr> means hold the CONTROL key while typing the character <chr>
Thus, C-f would be: hold the CONTROL key and type f.
M-<chr> means hold the META or EDIT key down while typing <chr>.
If there is no META or EDIT key, type <ESC>, release it,
then type the character <chr>. "<ESC>" stands for the
key labelled "ALT" or "ESC".
Important note: to end the Emacs session, type C-x C-c. (Two characters.)
The characters ">>" at the left margin indicate directions for you to
try using a command. For instance:
<<Blank lines inserted here by startup of help-with-tutorial>>
>> Now type C-v (View next screen) to move to the next screen.
(go ahead, do it by depressing the control key and v together).
From now on, you'll be expected to do this whenever you finish
reading the screen.
Note that there is an overlap when going from screen to screen; this
provides some continuity when moving through the file.
The first thing that you need to know is how to move around from
place to place in the file. You already know how to move forward a
screen, with C-v. To move backwards a screen, type M-v (depress the
META key and type v, or type <ESC>v if you don't have a META or EDIT
key).
>> Try typing M-v and then C-v to move back and forth a few times.
SUMMARY
-------
The following commands are useful for viewing screenfuls:
C-v Move forward one screenful
M-v Move backward one screenful
C-l Clear screen and redisplay everything
putting the text near the cursor at the center.
(That's control-L, not control-1.
There is no such character as control-1.)
>> Find the cursor and remember what text is near it.
Then type a C-l.
Find the cursor again and see what text is near it now.
BASIC CURSOR CONTROL
--------------------
Getting from screenful to screenful is useful, but how do you
reposition yourself within a given screen to a specific place?
There are several ways you can do this. One way (not the best, but
the most basic) is to use the commands previous, backward, forward
and next. As you can imagine these commands (which are given to
Emacs as C-p, C-b, C-f, and C-n respectively) move the cursor from
where it currently is to a new place in the given direction. Here,
in a more graphical form are the commands:
Previous line, C-p
:
:
Backward, C-b .... Current cursor position .... Forward, C-f
:
:
Next line, C-n
>> Move the cursor to the line in the middle of that diagram
and type C-l to see the whole diagram centered in the screen.
You'll probably find it easy to think of these by letter. P for
previous, N for next, B for backward and F for forward. These are
the basic cursor positioning commands and you'll be using them ALL
the time so it would be of great benefit if you learn them now.
>> Do a few C-n's to bring the cursor down to this line.
>> Move into the line with C-f's and then up with C-p's.
See what C-p does when the cursor is in the middle of the line.
Lines are separated by Newline characters. For most applications
there should normally be a Newline character at the end of the text,
as well, but it is up to you to make sure of this. A file can
validly exist without a Newline at the end.
>> Try to C-b at the beginning of a line. Do a few more C-b's.
Then do C-f's back to the end of the line and beyond.
When you go off the top or bottom of the screen, the text beyond
the edge is shifted onto the screen so that your instructions can
be carried out while keeping the cursor on the screen.
>> Try to move the cursor off the bottom of the screen with C-n and
see what happens.
If moving by characters is too slow, you can move by words. M-f
(Meta-f) moves forward a word and M-b moves back a word.
>> Type a few M-f's and M-b's. Intersperse them with C-f's and C-b's.
Notice the parallel between C-f and C-b on the one hand, and M-f and
M-b on the other hand. Very often Meta characters are used for
operations related to English text whereas Control characters operate
on the basic textual units that are independent of what you are
editing (characters, lines, etc). There is a similar parallel between
lines and sentences: C-a and C-e move to the beginning or end of a
line, and M-a and M-e move to the beginning or end of a sentence.
>> Try a couple of C-a's, and then a couple of C-e's.
Try a couple of M-a's, and then a couple of M-e's.
See how repeated C-a's do nothing, but repeated M-a's keep moving
farther. Do you think that this is right?
Two other simple cursor motion commands are M-< (Meta Less-than),
which moves to the beginning of the file, and M-> (Meta Greater-than),
which moves to the end of the file. You probably don't need to try
them, since finding this spot again will be boring. On most terminals
the "<" is above the comma and you must use the shift key to type it.
On these terminals you must use the shift key to type M-< also;
without the shift key, you would be typing M-comma.
The location of the cursor in the text is also called "point". To
paraphrase, the cursor shows on the screen where point is located in
the text.
Here is a summary of simple moving operations including the word and
sentence moving commands:
C-f Move forward a character
C-b Move backward a character
M-f Move forward a word
M-b Move backward a word
C-n Move to next line
C-p Move to previous line
C-a Move to beginning of line
C-e Move to end of line
M-a Move back to beginning of sentence
M-e Move forward to end of sentence
M-< Go to beginning of file
M-> Go to end of file
>> Try all of these commands now a few times for practice.
Since the last two will take you away from this screen,
you can come back here with M-v's and C-v's. These are
the most often used commands.
Like all other commands in Emacs, these commands can be given
arguments which cause them to be executed repeatedly. The way you
give a command a repeat count is by typing C-u and then the digits
before you type the command. If you have a META or EDIT key, you can
omit the C-u if you hold down the META or EDIT key while you type the
digits. This is easier, but we recommend the C-u method because it
works on any terminal.
For instance, C-u 8 C-f moves forward eight characters.
>> Try giving a suitable argument to C-n or C-p to come as close
as you can to this line in one jump.
The only apparent exception to this is the screen moving commands,
C-v and M-v. When given an argument, they scroll the screen up or
down by that many lines, rather than screenfuls. This proves to be
much more useful.
>> Try typing C-u 8 C-v now.
Did it scroll the screen up by 8 lines? If you would like to
scroll it down you can give an argument to M-v.
WHEN EMACS IS HUNG
-----------------
If Emacs gets into an infinite (or simply very long) computation which
you don't want to finish, you can stop it safely by typing C-g.
You can also use C-g to discard a numeric argument or the beginning of
a command that you don't want to finish.
>> Type C-u 100 to make a numeric arg of 100, then type C-g.
Now type C-f. How many characters does it move?
If you have typed an <ESC> by mistake, you can get rid of it
with a C-g.
If you type <ESC> <ESC>, you get a new window appearing on
the screen, telling you that M-ESC is a "disabled command"
and asking whether you really want to execute it. The command
M-ESC is marked as disabled because you probably don't want to
use it until you know more about Emacs, and we expect it would
confuse you if it were allowed to go ahead and run. If you really
want to try the M-ESC command, you could type a Space in answer
to the question and M-ESC would go ahead. Normally, if you do
not want to execute M-ESC, you would type "n" to answer the question.
>> Type <ESC> <ESC>, then typ