]> code.delx.au - gnu-emacs/blobdiff - etc/TUTORIAL
(custom-buffer-verbose-help): New variable.
[gnu-emacs] / etc / TUTORIAL
index d2f0bae698da4ca9a24d1d0cd0afbbd2742cb569..ad3911e4427be867e4cba9cd66d571ac305593d7 100644 (file)
@@ -14,9 +14,10 @@ write that in full each time, we'll use the following abbreviations:
 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>>
+<<Blank lines inserted around following line by help-with-tutorial>>
+[Middle of page left blank for didactic purposes.   Text continues below]
 >>  Now type C-v (View next screen) to move to the next screen.
-       (go ahead, do it by holding down the control key while typing v).
+       (go ahead, do it by holding down the CONTROL key while typing v).
        From now on, you should do this again whenever you finish
        reading the screen.
 
@@ -42,7 +43,7 @@ The following commands are useful for viewing screenfuls:
        C-l     Clear screen and redisplay all the text,
                 moving the text around the cursor
                 to the center of the screen.
-                (That's control-L, not control-1.)
+                (That's CONTROL-L, not CONTROL-1.)
 
 >> Find the cursor, and note what text is near it.
    Then type C-l.
@@ -59,8 +60,8 @@ move to a specific place within the text on the screen?
 There are several ways you can do this.  The most basic way is to use
 the commands C-p, C-b, C-f, and C-n.  Each of these commands moves the
 cursor one row or column in a particular direction on the screen.
-Here is a table showing these four commands and shows the directions
-they move:
+Here is a table showing these four commands and the directions they
+move:
  
                          Previous line, C-p
                                  :
@@ -84,7 +85,7 @@ time, so it would be of great benefit if you learn them now.
 >> 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.
 
-Each of text line ends with a Newline character, which serves to
+Each line of text ends with a Newline character, which serves to
 separate it from the following line.  The last line in your file ought
 to have a Newline at the end (but Emacs does not require it to have
 one).
@@ -108,7 +109,7 @@ without moving it off the screen.
    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.
+(META-f) moves forward a word and M-b moves back a word.
 
 >> Type a few M-f's and M-b's.
 
@@ -162,8 +163,8 @@ word and sentence moving commands:
 >> Try all of these commands now a few times for practice.
    These are the most often used commands.
 
-Two other important cursor motion commands are M-< (Meta Less-than),
-which moves to the beginning of the whole text, and M-> (Meta
+Two other important cursor motion commands are M-< (META Less-than),
+which moves to the beginning of the whole text, and M-> (META
 Greater-than), which moves to the end of the whole text.
 
 On most terminals, the "<" is above the comma, so you must use the
@@ -188,7 +189,7 @@ easily learn to use other advanced cursor motion commands as well.
 Most Emacs commands accept a numeric argument; for most commands, this
 serves as a repeat-count.  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 or ALT) key, there is another alternative way
+you have a META (or EDIT or ALT) key, there is another, alternative way
 to enter a numeric argument: type the digits while holding down the
 META key.  We recommend learning the C-u method because it works on
 any terminal.  The numeric argument is also called a "prefix argument",
@@ -214,9 +215,10 @@ screenful.  For example, C-u 8 C-v scrolls the screen by 8 lines.
 This should have scrolled the screen up by 8 lines.  If you would like
 to scroll it down again, you can give an argument to M-v.
 
-If you are using X Windows, there should be a tall rectangular area
-called a scroll bar at the left hand side of the Emacs window.  You
-can scroll the text by clicking the mouse in the scroll bar.
+If you are using a windowed display, such as X11 or MS-Windows, there
+should be a tall rectangular area called a scroll bar at the left hand
+side of the Emacs window.  You can scroll the text by clicking the
+mouse in the scroll bar.
 
 >> Try pressing the middle button at the top of the highlighted area
    within the scroll bar.  This should scroll the text to a position
@@ -273,20 +275,20 @@ one-window editing.  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 expands the window
+That is CONTROL-x followed by the digit 1.  C-x 1 expands the window
 which contains the cursor, to occupy the full screen.  It deletes all
 other windows.
 
 >> Move the cursor to this line and type C-u 0 C-l.
->> Type Control-h k Control-f.
+>> Type CONTROL-h k CONTROL-f.
    See how this window shrinks, while a new one appears
-   to display documentation on the Control-f command.
+   to display documentation on the CONTROL-f command.
 
 >> Type C-x 1 and see the documentation listing window disappear.
 
 This command is unlike the other commands you have learned in that it
-consists of two characters.  It starts with the character Control-x.
-There is a whole series of commands that start with Control-x; many of
+consists of two characters.  It starts with the character CONTROL-x.
+There is a whole series of commands that start with CONTROL-x; many of
 them have to do with windows, files, buffers, and related things.
 These commands are two, three or four characters long.
 
@@ -313,7 +315,8 @@ current cursor position.
 
 When a line of text gets too big for one line on the screen, the line
 of text is "continued" onto a second screen line.  A backslash ("\")
-at the right margin indicates a line which has been continued.
+(or, if you're using a windowed display, a little curved arrow) at the
+right margin indicates a line which has been continued.
 
 >> Insert text until you reach the right margin, and keep on inserting.
    You'll see a continuation line appear.
@@ -355,18 +358,26 @@ started by C-f and M-f (well, <Delete> is not really a control
 character, but let's not worry about that).  C-k and M-k are like C-e
 and M-e, sort of, in that lines are opposite sentences.
 
-When you delete more than one character at a time, Emacs saves the
-deleted text so that you can bring it back.  Bringing back killed text
-is called "yanking".  You can yank the killed text either at the same
-place where it was killed, or at some other place in the text.  You
-can yank the text several times in order to make multiple copies of
-it.  The command to yank is C-y.
-
-Note that the difference between "Killing" and "Deleting" something is
-that "Killed" things can be yanked back, and "Deleted" things cannot.
-Generally, the commands that can remove a lot of text save the text,
-while the commands that delete just one character, or just blank lines
-and spaces, do not save the deleted text.
+You can also kill any part of the buffer with one uniform method.
+Move to one end of that part, and type C-@ or C-SPC (either one).
+(SPC is the Space bar.)  Move to the other end of that part, and type
+C-w.  That kills all the text between the two positions.
+
+>> Move the cursor to the Y at the start of the previous paragraph.
+>> Type C-SPC.  Emacs should display a message "Mark set"
+   at the bottom of the screen.
+>> Move the cursor to the n in "end", on the second line of the
+   paragraph.
+>> Type C-w.  This will kill the text starting from the Y,
+   and ending just before the n.
+
+The difference between "killing" and "deleting" is that "killed" text
+can be reinserted, whereas "deleted" things cannot be reinserted.
+Reinsertion of killed text is called "yanking".  Generally, the
+commands that can remove a lot of text kill the text (they set up so
+that you can yank the text), while the commands that remove just one
+character, or just blank lines and spaces, do deletion (so you cannot
+yank that text).
 
 >> Move the cursor to the  beginning of a line which is not empty.
    Then type C-k to kill the text on that line.
@@ -374,20 +385,25 @@ and spaces, do not save the deleted text.
    which follows that line.
 
 Note that a single C-k kills the contents of the line, and a second
-C-k kills the line itself, and make all the other lines move up.  C-k
+C-k kills the line itself, and makes all the other lines move up.  C-k
 treats a numeric argument specially: it kills that many lines AND
 their contents.  This is not mere repetition.  C-u 2 C-k kills two
 lines and their newlines; typing C-k twice would not do that.
 
-To retrieve the last killed text and put it where the cursor currently
-is, type C-y.
+Bringing back killed text is called "yanking".  (Think of it as
+yanking back, or pulling back, some text that was taken away.)  You
+can yank the killed text either at the same place where it was killed,
+or at some other place in the buffer, or even in a different file.
+You can yank the text several times, which makes multiple copies of
+it.
+
+The command for yanking is C-y.  It reinserts the last killed text,
+at the current cursor position.
 
 >> Try it; type C-y to yank the text back.
 
-Think of C-y as if you were yanking something back that someone took
-away from you.  Notice that if you do several C-k's in a row, all of
-the killed text is saved together, so that one C-y will yank all of
-the lines.
+If you do several C-k's in a row, all of the killed text is saved
+together, so that one C-y will yank all of the lines at once.
 
 >> Do this now, type C-k several times.
 
@@ -444,6 +460,10 @@ by typing / while holding down CONTROL.
 
 A numeric argument to C-_ or C-x u acts as a repeat count.
 
+You can undo deletion of text just as you can undo killing of text.
+The distinction between killing something and deleting it affects
+whether you can yank it with C-y; it makes no difference for undo.
+
 
 * FILES
 -------
@@ -504,12 +524,12 @@ do this, Emacs renames the original file to a new name so that it is
 not lost.  The new name is made by adding "~" to the end of the
 original file's name.
 
-When saving is finished, Emacs prints the name of the file written.
+When saving is finished, Emacs displays the name of the file written.
 You should save fairly often, so that you will not lose very much
 work if the system should crash.
 
 >> Type C-x C-s, saving your copy of the tutorial.
-   This should print "Wrote ...TUTORIAL" at the bottom of the screen.
+   This should show "Wrote ...TUTORIAL" at the bottom of the screen.
 
 NOTE: On some systems, typing C-x C-s will freeze the screen and you
 will see no further output from Emacs.  This indicates that an
@@ -547,15 +567,39 @@ buffers that currently exist in your Emacs job, type
 
 >> Try C-x C-b now.
 
-See how each buffer has a name, and it may also have a file name
-for the file whose contents it holds.  Some buffers do not correspond
-to files.  For example, the buffer named "*Buffer List*" does
-not have any file.  It is the buffer which contains the buffer
-list that was made by C-x C-b.  ANY text you see in an Emacs window
+See how each buffer has a name, and it may also have a file name for
+the file whose contents it holds.  ANY text you see in an Emacs window
 is always part of some buffer.
 
 >> Type C-x 1 to get rid of the buffer list.
 
+When you have several buffers, only of of them is "current" at any
+time.  That buffer is the one you edit.  If you want to edit another
+buffer, you need to "switch" to it.  If you want to switch to a buffer
+that corresponds to a file, you can do it by visiting the file again
+with C-x C-f.  But there is an easier way: use the C-x b command.
+In that command, you have to type the buffer's name.
+
+>> Type C-x b foo <Return> to go back to the buffer "foo" which holds
+   the text of the file "foo".  Then type C-x b TUTORIAL <Return>
+   to come back to this tutorial.
+
+Most of the time, the buffer's name is the same as the file name
+(without the file directory part).  However, this is not always true.
+The buffer list you make with C-x C-b always shows you the name of
+every buffer.
+
+ANY text you see in an Emacs window is always part of some buffer.
+Some buffers do not correspond to files.  For example, the buffer
+named "*Buffer List*" does not have any file.  It is the buffer which
+contains the buffer list that you made with C-x C-b.  The buffer named
+"*Messages*" also does not correspond to any file; it contains the
+messages that have appeared on the bottom line during your Emacs
+session.
+
+>> Type C-x b *Messages* <Return> to look at the buffer of messages.
+   Then type C-b TUTORIAL <Return> to come back to this tutorial.
+
 If you make changes to the text of one file, then find another file,
 this does not save the first file.  Its changes remain inside Emacs,
 in that file's buffer.  The creation or editing of the second file's
@@ -618,6 +662,7 @@ There are many C-x commands.  Here is a list of the ones you have learned:
        C-x C-s         Save file.
        C-x C-b         List buffers.
        C-x C-c         Quit Emacs.
+       C-x 1           Delete all but one window.
        C-x u           Undo.
 
 Named eXtended commands are commands which are used even less
@@ -626,7 +671,9 @@ example is the command replace-string, which globally replaces one
 string with another.  When you type M-x, Emacs prompts you at the
 bottom of the screen with M-x and you should type the name of the
 command; in this case, "replace-string".  Just type "repl s<TAB>" and
-Emacs will complete the name.  End the command name with <Return>.
+Emacs will complete the name.  (<TAB> is the Tab key, usually found
+above the CapsLock or Shift key near the left edge of the keyboard.)
+End the command name with <Return>.
 
 The replace-string command requires two arguments--the string to be
 replaced, and the string to replace it with.  You must end each
@@ -661,15 +708,15 @@ data.
 * ECHO AREA
 -----------
 
-If Emacs sees that you are typing commands slowly it shows them to you
-at the bottom of the screen in an area called the "echo area".  The echo
-area contains the bottom line of the screen.
+If Emacs sees that you are typing multicharacter commands slowly, it
+shows them to you at the bottom of the screen in an area called the
+"echo area".  The echo area contains the bottom line of the screen.
 
 
 * MODE LINE
 -----------
 
-The line immediately above the echo area it is called the "mode line".
+The line immediately above the echo area is called the "mode line".
 The mode line says something like this:
 
 --:**  TUTORIAL          (Fundamental)--L670--58%----------------
@@ -685,6 +732,9 @@ top of the file is on the screen, it will say --Top-- instead of
 --Bot--.  If you are looking at text so small that all of it fits on
 the screen, the mode line says --All--.
 
+The L and digits indicate position in another way: they give the
+current line number of point.
+
 The stars near the front mean that you have made changes to the text.
 Right after you visit or save a file, that part of the mode line shows
 no stars, just dashes.
@@ -711,7 +761,7 @@ If you are going to be editing English text, such as this file, you
 should probably use Text Mode.
 >> Type M-x text mode<Return>.
 
-Don't worry, none of the commands you have learned changes Emacs in
+Don't worry, none of the  Emacs commands you have learned changes in
 any great way.  But you can observe that M-f and M-b now treat
 apostrophes as part of words.  Previously, in Fundamental mode,
 M-f and M-b treated apostrophes as word-separators.
@@ -727,7 +777,7 @@ To view documentation on your current major mode, type C-h m.
 >> Type C-x 1 to remove the documentation from the screen.
 
 Major modes are called major because there are also minor modes.
-Minor modes are alternatives not to the major modes, just minor
+Minor modes are not alternatives to the major modes, just minor
 modifications of them.  Each minor mode can be turned on or off by
 itself, independent of all other minor modes, and independent of your
 major mode.  So you can use no minor modes, or one minor mode, or any
@@ -739,7 +789,7 @@ in between words automatically whenever you insert text and make a
 line that is too wide.
 
 You can turn Auto Fill mode on by doing M-x auto fill mode<Return>.
-When the mode is on, you can turn it off by doing M-x
+When the mode is on, you can turn it off again by doing M-x
 auto fill mode<Return>.  If the mode is off, this command turns it on,
 and if the mode is on, this command turns it off.  We say that the
 command "toggles the mode".
@@ -757,9 +807,9 @@ as a numeric argument.
    characters with it.  Then set the margin back to 70 using
    C-x f again.
 
-If you makes changes in the middle of a paragraph, Auto Fill mode
+If you make changes in the middle of a paragraph, Auto Fill mode
 does not re-fill it for you.
-To re-fill the paragraph, type M-q (Meta-q) with the cursor inside
+To re-fill the paragraph, type M-q (META-q) with the cursor inside
 that paragraph.
 
 >> Move the cursor into the previous paragraph and type M-q.
@@ -796,8 +846,8 @@ you want to search for.  <Return> terminates a 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.
+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
@@ -832,13 +882,14 @@ the search is reversed.
 One of the nice features of Emacs is that you can display more than one
 window on the screen at the same time.
 
->> Move the cursor to this line and type C-u 0 C-l.
+>> Move the cursor to this line and type C-u 0 C-l (that's CONTROL-L, not
+   CONTROL-1).
 
 >> Now type C-x 2 which splits the screen into two windows.
    Both windows display this tutorial.  The cursor stays in the top window.
 
 >> Type C-M-v to scroll the bottom window.
-   (If you do not have a real Meta key, type ESC C-v.)
+   (If you do not have a real META key, type ESC C-v.)
 
 >> Type C-x o ("o" for "other") to move the cursor to the bottom window.
 >> Use C-v and M-v in the bottom window to scroll it.
@@ -863,8 +914,8 @@ typing v.  It does not matter whether CONTROL or META "comes first,"
 because both of these keys act by modifying the characters you type.
 
 If you do not have a real META key, and you use ESC instead, the order
-does matter: you must type ESC followed by Control-v, because
-Control-ESC v will not work.  This is because ESC is a character in
+does matter: you must type ESC followed by CONTROL-v, because
+CONTROL-ESC v will not work.  This is because ESC is a character in
 its own right, not a modifier key.
 
 >> Type C-x 1 (in the top window) to get rid of the bottom window.
@@ -916,7 +967,7 @@ it would be impossible to explain it all here.  However, you may want
 to learn more about Emacs since it has many other useful features.
 Emacs provides commands for reading documentation about Emacs
 commands.  These "help" commands all start with the character
-Control-h, which is called "the Help character".
+CONTROL-h, which is called "the Help character".
 
 To use the Help features, type the C-h character, and then a
 character saying what kind of help you want.  If you are REALLY lost,
@@ -934,7 +985,7 @@ The most basic HELP feature is C-h c.  Type C-h, the character c, and
 a command character or sequence; then Emacs displays a very brief
 description of the command.
 
->> Type C-h c Control-p.
+>> Type C-h c C-p.
   The message should be something like
 
        C-p runs the command previous-line
@@ -950,7 +1001,7 @@ EDIT or ALT key) <ESC>v are also allowed after C-h c.
 
 To get more information about a command, use C-h k instead of C-h c.
 
->> Type C-h k Control-p.
+>> Type C-h k C-p.
 
 This displays the documentation of the function, as well as its
 name, in an Emacs window.  When you are finished reading the
@@ -964,12 +1015,16 @@ Here are some other useful C-h options:
                function.
 
 >> Try typing C-h f previous-line<Return>.
-   This prints all the information Emacs has about the
+   This displays all the information Emacs has about the
    function which implements the C-p command.
 
+A similar command C-h v displays the documentation of variables whose
+values you can set to customize Emacs behavior.  You need to type in
+the name of the variable when Emacs prompts for it.
+
    C-h a       Command Apropos.  Type in a keyword and Emacs will list
                all the commands whose names contain that keyword.
-               These commands can all be invoked with Meta-x.
+               These commands can all be invoked with META-x.
                For some commands, Command Apropos will also list a one
                or two character sequence which runs the same command.
 
@@ -983,6 +1038,38 @@ beside the corresponding command names such as find-file.
 
 >> Type C-x 1 to delete the help window.
 
+   C-h i       Read On-line Manuals (a.k.a. Info).  This command puts
+               you into a special buffer called `*info*' where you
+               can read on-line manuals for the packages installed on
+               your system.  Type m emacs <Return> to read the Emacs
+               manual.  If you have never before used Info, type ?
+               and Emacs will take you on a guided tour of Info mode
+               facilities.  Once you are through with this tutorial,
+               you should consult the Emacs Info manual as your
+               primary documentation.
+
+
+* MORE FEATURES
+---------------
+
+You can learn more about Emacs by reading its manual, either as a book
+or on-line in Info (use the Help menu or type F10 h r).  Two features
+that you may like especially are completion, which saves typing, and
+dired, which simplifies file handling.
+
+Completion is a way to avoid unnecessary typing.  For instance, if you
+want to switch to the *Messages* buffer, you can type C-x b *M<Tab>
+and Emacs will fill in the rest of the buffer name as far as it can
+determine from what you have already typed.  Completion is described
+in Info in the Emacs manual in the node called "Completion".
+
+Dired enables you to list files in a directory (and optionally its
+subdirectories), move around that list, visit, rename, delete and
+otherwise operate on the files.  Dired is described in Info in the
+Emacs manual in the node called "Dired".
+
+The manual also describes many other Emacs features.
+
 
 * CONCLUSION
 ------------