home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
useful
/
util
/
edit
/
mg
/
docs
/
tutorial
< prev
Wrap
Text File
|
1990-06-02
|
25KB
|
605 lines
Copyright (c) 1985 Richard M. Stallman. See end for copying conditions.
You are looking at the Emacs tutorial.
Emacs commands generally involve the CONTROL key or the META (ESC)
key. 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 type <ESC>, release it, then type the character <chr>.
The characters ">>" at the left margin indicate directions for you to
try using a command. For instance:
>> 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 (type <ESC>v).
>> 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. It is also
possible to move the cursor with the arrow keys, but this requires you
move your hand from the keyboard, it is also not supported on other
machines that do support Emacs. Emacs runs on everything from a CP/M
machine to large mainframes. Here then, 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.
>> 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
(ESC-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). C-a and C-e move to the beginning or
end of a line.
>> Try a couple of C-a's, and then a couple of C-e's.
See how repeated C-a's do nothing.
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-< 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.
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.
WINDOWS
-------
Emacs can have several windows, each displaying its own text.
At this stage it is better not to go into the techniques of
using multiple windows. But you do need to know how to get
rid of extra windows that may appear to display help or
output from certain commands. It is simple:
C-x 1 One window (i.e., kill all other windows).
That is Control-x followed by the digit 1.
C-x 1 makes the window which the cursor is in become
the full screen, by getting rid of any other windows.
>> Move the cursor to this line and type C-l (Control-L).
>> Type M-x. The cursor will move to the bottom of the screen.
>> Type the words "describe-bindings" and hit return.
See how this window shrinks, while a new one appears
to display which functions are connected to which keys.
>> Type C-x 1 and see the documentation listing window disappear.
INSERTING AND DELETING
----------------------
If you want to insert text, just type it. Characters which you can
see, such as A, 7, *, etc. are taken by Emacs as text and inserted
immediately. Type <Return> (the carriage-return key) to insert a
Newline character.
You can delete the last character you typed by typing <DEL>. More
generally, <DEL> deletes the character immediately before the current
cursor position.
>> Do this now, type a few characters and then delete them
by typing <DEL> a few times. Don't worry about this file
being changed; you won't affect the master tutorial. This is just
a copy of it.
>> Now start typing text until y