[ This is the latest revision of one of two programs named "MicroEmacs";
when discussing these on the net, or in contacting the authors, make
sure to mention the version number -- in this case 3.7 -- as that is
the easiest way to distinguish between them. Daniel will be posting
uuencoded executables in net.micro.pc and net.micro.amiga; the file
'readme' contains information on how to also get these from him
directly. --r$ ]
echo extracting - emacs.tut
sed 's/^X//' > emacs.tut << 'FRIDAY_NIGHT'
XYou are looking at the MICRO-EMACS tutorial. Comments on this document
Xmay be refered to Dana Hoggatt or Dan Lawrance.
X
XEMACS commands generally involve the CONTROL key (sometimes labelled CTRL or
XCTL) or the META key (generally labelled ESCAPE). Rather than write out META
Xor CONTROL each time we want you to prefix a character, we'll use the following
Xabbreviations:
X
X ^<chr> means hold the CONTROL key while typing the character <chr>
X Thus, ^F would be: hold the CONTROL key and type F.
X
X ESC-<chr> means type the ESCAPE key and release it, then type the
X character <chr>. The <chr> can be upper or lower case
X and it will have the same meaning.
X
XImportant note: if you must exit at some point, type ^X ^C.
X
XThis tutorial attempts to help you "learn by doing". The characters ">>"
Xat the left margin of your screen indicate directions for you to try using
Xa command. For instance:
X
X>> Now type ^V (View next screen) to move to the next screen.
X (go ahead, do it by depressing the control key and V together).
X
XFrom now on, you'll be expected to type ^V whenever you finish reading the
Xcurrent screen.
X
XNote that there is an overlap when going from screen to screen; this
Xprovides some continuity when moving through the file.
X
XThe first thing that you need to know is how to move around from place to
Xplace in the file. You already know how to move forward a screen, with ^V.
XTo move backwards a screen, type ^Z. (depress the CTRL key and type Z).
X
X>> Try typing ^Z and then ^V to move back and forth a few times.
X
X
XSUMMARY
X-------
X
XThe following commands are useful for viewing screenfuls:
X
X ^V Move forward one screenful
X ^Z Move backward one screenful
X <ESC>^L Clear screen and redisplay everything
X putting the text near the cursor at the center.
X
X>> find the cursor and remember what text is near it.
X Then type a <ESC>^L.
X Find the cursor again and see what text is near it now.
X
X
XBASIC CURSOR CONTROL
X--------------------
X
XGetting from screenful to screenful is useful, but how do you reposition
Xyourself within a given screen to a specific place? There are several ways
Xyou can do this. One way (not the best, but the most basic) is to use the
Xcommands previous, backward, forward and next. As you can imagine these
Xcommands (which are given to EMACS as ^P, ^B, ^F, and ^N respectively) move
Xthe cursor from where it currently is to a new place in the given direction.
XHere, in a more graphical form are the commands:
X
X Previous line, ^P
X :
X :
X Backward, ^B .... Current cursor position .... Forward, ^F
X :
X :
X Next line, ^N
X
XYou'll probably find it easy to think of these by letter. P for
Xprevious, N for next, B for backward and F for forward. These are
Xthe basic cursor positioning commands and you'll be using them ALL
Xthe time so it would be of great benefit if you learn them now.
X
X>> Do a few ^N's to bring the cursor down to this line.
X
X>> Move into the line with ^F's and then up with several ^P's.
X See what ^P does when the cursor is in the middle of the line.
X
XLines are separated by a single Linefeed character, which is what
XUnix calls a Newline.
X
X>> Try to ^B at the beginning of a line. Do a few more ^B's.
X Then do ^F's back to the end of the line and beyond.
X
XWhen you go off the top or bottom of the screen, the text beyond
Xthe edge is shifted onto the screen so that your instructions can
Xbe carried out while keeping the cursor on the screen.
X
X>> Try to move the cursor off the bottom of the screen with ^N and
X see what happens.
X
XIf moving by characters is too slow, you can move by words. ESC-F
X(Meta-F) moves forward a word and ESC-B moves back a word.
X
X>> Type a few ESC-F's and ESC-B's. Intersperse them with ^F's and ^B's.
X
XNotice the parallel between ^F and ^B on the one hand, and ESC-F and ESC-B on
Xthe other hand. Very often Meta characters are used for operations related
Xto English text whereas Control characters operate on the basic textual units
Xthat are independent of what you are editing (characters, lines, etc). There
Xis a similar parallel between lines and sentences: ^A and ^E move to the
Xbeginning or end of a line. and ESC-A and ESC-E move to the beginning or end
Xof a sentence.
X
X### Note: ESC-A and ESC-E are not implimented yet (DLH - 1/22/86) ###
X
X>> Try a couple of ^A's, and then a couple of ^E's.
X Try a couple of ESC-A's, and then a couple of ESC-E's.
X
XSee how repeated ^A's do nothing, but repeated ESC-A's
Xkeep moving farther. Do you think that this is right?
X
XTwo other simple cursor motion commands are ESC-< (Meta Less-than),
Xwhich moves to the beginning of the file, and ESC-> (Meta Greater-than),
Xwhich moves to the end of the file. You probably don't need to try
Xthem, since finding this spot again will be boring. If you need the
Xshift key to type a "<", then you must also use the shift key to type
XESC-<. Otherwise, you would be typing ESC-, .
X
XThe location of the cursor within the text is also called "point". To
Xparaphrase, the cursor shows on the screen where point is located in the text.
X
XHere is a summary of simple moving operations including
Xthe word and sentence moving commands:
X
X ^F Move forward a character
X ^B Move backward a character
X
X ESC-F Move forward a word
X ESC-B Move backward a word
X
X ^N Move to next line
X ^P Move to previous line
X
X ESC-N Move to next paragraph
X ESC-P Move to previous paragraph
X
X ^A Move to beginning of line
X ^E Move to end of line
X
X ESC-A Move back to beginning of sentence (not functional)
X ESC-E Move forward to end of sentence (not functional)
X
X ESC-< Go to beginning of file
X ESC-> Go to end of file
X
X>> Try all of these commands now a few times for practice.
X Since the last two will take you away from this screen,
X you can come back here with ^Z's and ^V's. These are
X the most often used commands.
X
XLike all other commands in EMACS, these commands can be given
Xarguments which cause them to be executed repeatedly. The way you
Xgive a command a repeat count is by typing META and then the digits
Xbefore you type the command. (Remember META is ususally called ESCAPE)
X
XFor instance, META 8 ^F moves forward eight characters.
X
X>> Try giving a suitable argument to ^N or ^P to come as close
X as you can to this line in one jump.
X
XThis also applies to the screen moving commands, ^V and ^Z. When
Xgiven an argument, they scroll the screen up or down by that many
Xscreenfuls. As a special case, typing just ^U is equivalent to ESC-4.
X
X>> Try typing ESC-3 ^V now.
X
XIf you would like to scroll it down, you can give an argument to ^Z.
X
X
XQUITTING FROM COMMANDS
X----------------------
X
XThe character in EMACS used to quit out of all commands which request
Xinput is ^G. For example, you can use ^G to discard a numeric argument
Xor the beginning of a command that you don't want to finish.
X
X>> Type ESC-100 to make a numeric arg of 100, then type ^G.
X Now type ^F. How many characters does it move?
X If you have typed an <ESC> by mistake, you can get rid of it
X with a ^G.
X
X
XIBM CURSOR KEYS
X---------------
X
XOn the IBM-PC version, the cursor keypad has been bound to some of the
Xmore useful screen movement commands. The mappings are as follows:
X
X Cursor-Right ^F Move forward a character
X Cursor-Left ^B Move backward a character
X
X ^Cursor-Right ESC-F Move forward a word
X ^Cursor-Left ESC-B Move backward a word
X
X Cursor-Down ^N Move to next line
X Cursor-UP ^P Move to previous line
X
X Pg-Dn ^V Move to next screen
X Pg-Up ^Z Move to previous screen
X
X Home ESC-< Go to beginning of file
X End ESC-> Go to end of file
X
X Insert ^O Open up a new line
X Delete ^K Kill to end of line
X
XUsage of the ^O and ^K commands is described later in the tutorial. A
Xmap of the key layout looks something like this:
X
X -------------------------------------------------
X | 7 | 8 | 9 |
X | Home | ^ | Pg Up |
X | | | | |
X | ESC-< | ^P | ^Z |
X -------------------------------------------------
X | 4 | 5 | 6 |
X | <-- | | --> |
X | | | |
X | ^B | | ^F |
X -------------------------------------------------
X | 1 | 2 | 3 |
X | End | | | Pg Dn |
X | | v | |
X | ESC-> | ^N | ^V |
X -------------------------------------------------------------
X | 0 | . |
X | Insert | Delete |
X | | |
X | ^O | ^K |
X -------------------------------------------------------------
X
X>> if you have an IBM-PC, practice using the cursor keypad.
X
X
X
XERRORS
X------
X
XSometimes you may do something which EMACS doesn't allow. If it is
Xsomething simple, such as typing a control key sequence which is not
Xassociated with any command, EMACS will just beep at you. Otherwise,
XEMACS will also display an informative error message at the bottom of
Xthe screen.
X
XSome versions of EMACS do not have all the features described in this
Xtutorial implemented yet. If you come across such an unimplemented
Xfeature, you may get an error message when you try to use it. Just
Xtype a space and proceed on to the next section of the tutorial.
X
X
XINSERTING AND DELETING
X----------------------
X
XIf you want to type text, just do it. Characters which you can see, such
Xas A, 7, *, etc. are taken by EMACS as text and are immediately inserted.
XType <Return> (the carriage-return key) to insert a line separator.
X
XYou can delete the last character you typed by typing either <Delete> or ^H.
XOn some keyboards, there is a dedicated key for creating a ^H. If so, it is
Xusually labeled as either "Backspace" or "<--". <Delete> is a key on the
Xkeyboard, which may be labeled "Rubout" instead of "Delete" on some terminals.
XMore generally, <Delete> deletes the character immediately before the current
Xcursor position.
X
X>> Do this now, type a few characters and then delete them by typing
X <Delete> a few times. Don't worry about this file being changed;
X you won't affect the master tutorial. This is just a copy of it.
X
X>> Now start typing text until you reach the right margin, and keep
X typing. When a line of text gets too big for one line on the
X screen, the line of text is "continued" off the edge of the screen
X The dollar sign at the right margin indicates a line which has
X been continued. EMACS scrolls the line over so you can see what you
X are editing. The '$' at the left or right edge of the screen indicates
X that the current line extends off in that direction.
X
X>> The following line actually goes off the edge. Trying typing enough ^F's
X so that you move off the right hand end of this line. This is a long line of text. Note the "$"s at each edge. Keep typing ^F's and watch where EMACS decides to scroll the line. Now, type ^B's until EMACS decides to scroll the line again.
X
XThis is one of those gizmos which is easier to understand by playing with it
Xthan by reading about it.
X
X>> Use ^D's or <Delete>s to delete the text until the text line fits on
X one screen line again. The continuation "$" will go away.
X
X>> Move the cursor to the beginning of a line and type <Delete>. This
X deletes the line separator before the line and merges the line onto
X the previous line. The resulting line may be too long to fit, in
X which case it has a continuation indication.
X
X>> Type <Return> to insert the separator again.
X
XInternally, EMACS will allow you to have lines of nearly any length, limited
Xonly by the amount of memory available. Externally, however, EMACS can only
Xread or write lines, to or from a file, which are less than or equal to 255
Xcharacters.
X
XRemember that most EMACS commands can be given a repeat count; Note
Xthat this includes characters which insert themselves.
X
X>> Try that now -- type META 8 * and see what happens.
X
XIf you want to create a blank line in between two lines, move to the
Xsecond of the two lines and type ^O.
X
X>> Try moving to a line and typing ^O now.
X
XYou've now learned the most basic way of typing something in
XEMACS and correcting errors. You can delete by words or lines
Xas well. Here is a summary of the delete operations:
X
X <Delete> delete the character just before the cursor
X ^H delete the character just before the cursor
X ^D delete the next character after the cursor
X
X ESC-<Delete> kill the word immediately before the cursor
X ESC-^H kill the word immediately before the cursor
X ESC-D kill the next word after the cursor
X
X ^K kill from the cursor position to end of line
X
XNotice that <Delete> and ^D vs ESC-<Delete> and ESC-D extend the parallel
Xstarted by ^F and ESC-F (well, <Delete> isn't really a control
Xcharacter, but let's not worry about that).
X
XNow suppose you kill something, and then you decide that you want to get
Xit back? Well, whenever you kill something bigger than a character, EMACS
Xsaves it for you. To yank it back, use ^Y. Note that you don't have to
Xbe in the same place to do ^Y; This is a good way to move text around.
XAlso note that the difference between "Killing" and "Deleting" something
Xis that "Killed" things can be yanked back, and "Deleted" things cannot.
XGenerally, the commands that can destroy a lot of text save it, while the
Xones that attack only one character, or nothing but blank lines and spaces,
Xdo not save.
X
XFor instance, type ^N a couple times to postion the cursor
Xat some line on this screen.
X
X>> Do this now, move the cursor and kill that line with ^K.
X
XNote that a single ^K kills the contents of the line, and a second
X^K kills the line itself, and make all the other lines move up. If
Xyou give ^K a repeat count, it kills that many lines AND their contents.
X
XThe text that has just disappeared is saved so that you can
Xretrieve it. To retrieve the last killed text and put it where
Xthe cursor currently is, type ^Y.
X
X>> Try it; type ^Y to yank the text back.
X
XThink of ^Y as if you were yanking something back that someone took away
Xfrom you. Notice that if you do several ^K's in a row the text that is
Xkilled is all saved together so that one ^Y will yank all of the lines.
X
X>> Do this now, type ^K several times.
X
XNow to retrieve that killed text:
X
X>> Type ^Y. Then move the cursor down a few lines and type ^Y
X again. You now see how to copy some text.
X
XWhat do you do if you have some text you want to yank back, and then
Xyou kill something else? ^Y would yank the more recent kill.
X
X>> Kill a line, move around, kill another line.
X Then do ^Y to get back the second killed line.
X
X
XFILES
X-----
X
XIn order to make the text you edit permanent, you must put it in a file.
XOtherwise, it will go away when you leave EMACS. While you are editing a
Xfile in EMACS, your changes are actually being made to a private
X"scratch" copy of the file. However, the changes still don't become
Xpermanent until you "save" the file. This is so you can have control to
Xavoid leaving a half-changed file around when you don't want to.
X
XIf you look near the botton of the screen you will see a line that