comparison etc/TUTORIAL @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 376386a54a3c
children 3bb7ccffb0c0
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 Copyright (c) 1985, 1994 Free Software Foundation, Inc. 1 Copyright (c) 1985, 1996 Free Software Foundation, Inc. See end for conditions.
2 See end for conditions.
3 2
4 You are looking at the Emacs tutorial. 3 You are looking at the Emacs tutorial.
5 4
6 Emacs commands generally involve the CONTROL key (sometimes labelled 5 Emacs commands generally involve the CONTROL key (sometimes labelled
7 CTRL or CTL) or the META key. On some keyboards, the META key is 6 CTRL or CTL) or the META key. On some keyboards, the META key is
36 key). 35 key).
37 36
38 >> Try typing M-v and then C-v to move back and forth a few times. 37 >> Try typing M-v and then C-v to move back and forth a few times.
39 38
40 39
41 SUMMARY 40 * SUMMARY
42 ------- 41 ---------
43 42
44 The following commands are useful for viewing screenfuls: 43 The following commands are useful for viewing screenfuls:
45 44
46 C-v Move forward one screenful 45 C-v Move forward one screenful
47 M-v Move backward one screenful 46 M-v Move backward one screenful
54 >> Find the cursor and remember what text is near it. 53 >> Find the cursor and remember what text is near it.
55 Then type a C-l. 54 Then type a C-l.
56 Find the cursor again and see what text is near it now. 55 Find the cursor again and see what text is near it now.
57 56
58 57
59 BASIC CURSOR CONTROL 58 * BASIC CURSOR CONTROL
60 -------------------- 59 ----------------------
61 60
62 Getting from screenful to screenful is useful, but how do you 61 Getting from screenful to screenful is useful, but how do you
63 reposition yourself within a given screen to a specific place? 62 reposition yourself within a given screen to a specific place?
64 There are several ways you can do this. One way (not the best, but 63 There are several ways you can do this. One way (not the best, but
65 the most basic) is to use the commands previous, backward, forward 64 the most basic) is to use the commands previous, backward, forward
182 >> Try typing C-u 8 C-v now. 181 >> Try typing C-u 8 C-v now.
183 182
184 Did it scroll the screen up by 8 lines? If you would like to 183 Did it scroll the screen up by 8 lines? If you would like to
185 scroll it down you can give an argument to M-v. 184 scroll it down you can give an argument to M-v.
186 185
187 186 If you are using X Windows, there is probably a rectangular area
188 CURSOR CONTROL WITH AN X TERMINAL 187 called a scroll bar at the right hand side of the Emacs window. You
189 --------------------------------- 188 can scroll the text by manipulating the scroll bar with the mouse.
189
190 >> Try pressing the middle button at the top of the highlighted area
191 within the scroll bar, then moving the mouse while holding that button
192 down.
193
194 >> Move the mouse to a point in the scroll bar about three lines from
195 the top, and click the left button a couple of times.
196
197
198 * CURSOR CONTROL WITH AN X TERMINAL
199 -----------------------------------
190 200
191 If you have an X terminal, you will probably find it easier to use 201 If you have an X terminal, you will probably find it easier to use
192 the keys on the keypad to control the cursor. The left, right, up, 202 the keys on the keypad to control the cursor. The left, right, up,
193 and down arrow keys move in the expected direction; they function 203 and down arrow keys move in the expected direction; they function
194 exactly like C-b, C-f, C-p, and C-n, but are easier to type and to 204 exactly like C-b, C-f, C-p, and C-n, but are easier to type and to
206 words to the right, type C-1 C-2 C-right. Note that it is very easy 216 words to the right, type C-1 C-2 C-right. Note that it is very easy
207 to type this because you do not have to release the CONTROL key 217 to type this because you do not have to release the CONTROL key
208 between keystrokes. 218 between keystrokes.
209 219
210 220
211 WHEN EMACS IS HUNG 221 * WHEN EMACS IS HUNG
212 ------------------ 222 --------------------
213 223
214 If Emacs gets into an infinite (or simply very long) computation which 224 If Emacs gets into an infinite (or simply very long) computation which
215 you don't want to finish, you can stop it safely by typing C-g. 225 you don't want to finish, you can stop it safely by typing C-g.
216 You can also use C-g to discard a numeric argument or the beginning of 226 You can also use C-g to discard a numeric argument or the beginning of
217 a command that you don't want to finish. 227 a command that you don't want to finish.
219 >> Type C-u 100 to make a numeric arg of 100, then type C-g. 229 >> Type C-u 100 to make a numeric arg of 100, then type C-g.
220 Now type C-f. How many characters does it move? 230 Now type C-f. How many characters does it move?
221 If you have typed an <ESC> by mistake, you can get rid of it 231 If you have typed an <ESC> by mistake, you can get rid of it
222 with a C-g. 232 with a C-g.
223 233
224 If you type <ESC> <ESC>, you get a new window appearing on 234 If you type <ESC> : then you get a new window appearing on the screen,
225 the screen, telling you that M-ESC is a "disabled command" 235 telling you that M-: is a "disabled command" and asking whether you
226 and asking whether you really want to execute it. The command 236 really want to execute it. The command M-: is marked as disabled
227 M-ESC is marked as disabled because you probably don't want to 237 because we expect it would confuse beginners and you probably don't
228 use it until you know more about Emacs, and we expect it would 238 want to use it until you know more about Emacs. If you really want to
229 confuse you if it were allowed to go ahead and run. If you really 239 try the M-: command, you could type a Space in answer to the question,
230 want to try the M-ESC command, you could type a Space in answer 240 and M-: would go ahead. Normally, if you do not want to execute M-:,
231 to the question and M-ESC would go ahead. Normally, if you do 241 you would type "n" to answer the question.
232 not want to execute M-ESC, you would type "n" to answer the question. 242
233 243 >> Type <ESC> :, then type n.
234 >> Type <ESC> <ESC>, then type n. 244
235 245
236 246 * WINDOWS
237 WINDOWS 247 ---------
238 -------
239 248
240 Emacs can have several windows, each displaying its own text. 249 Emacs can have several windows, each displaying its own text.
241 Note that "window" as used by Emacs does not refer to separate 250 Note that "window" as used by Emacs does not refer to separate
242 overlapping windows in the window system, but to separate panes 251 overlapping windows in the window system, but to separate panes
243 within a single X window. (Emacs can also have multiple X 252 within a single X window. (Emacs can also have multiple X
244 windows, or "screens" in Emacs terminology. This is described 253 windows, or "frames" in Emacs terminology. This is described
245 later.) 254 later.)
246 255
247 At this stage it is better not to go into the techniques of 256 At this stage it is better not to go into the techniques of
248 using multiple windows. But you do need to know how to get 257 using multiple windows. But you do need to know how to get
249 rid of extra windows that may appear to display help or 258 rid of extra windows that may appear to display help or
268 to display documentation on the Control-f command. 277 to display documentation on the Control-f command.
269 278
270 >> Type C-x 1 and see the documentation listing window disappear. 279 >> Type C-x 1 and see the documentation listing window disappear.
271 280
272 281
273 INSERTING AND DELETING 282 * INSERTING AND DELETING
274 ---------------------- 283 ------------------------
275 284
276 If you want to insert text, just type it. Characters which you can 285 If you want to insert text, just type it. Characters which you can
277 see, such as A, 7, *, etc. are taken by Emacs as text and inserted 286 see, such as A, 7, *, etc. are taken by Emacs as text and inserted
278 immediately. Type <Return> (the carriage-return key) to insert a 287 immediately. Type <Return> (the carriage-return key) to insert a
279 Newline character. 288 Newline character.
280 289
281 You can delete the last character you typed by typing <Rubout>. 290 You can delete the last character you typed by typing <Delete>.
282 On X terminals, <Rubout> is normally the key labelled BACK SPACE. 291 <Delete> is a key on the keyboard, which may be labeled "Del". In
292 some cases, the "Backspace" key serves as <Delete>, but not always!
293
294 More generally, <Delete> deletes the character immediately before the
295 current cursor position.
283 296
284 >> Do this now, type a few characters and then delete them 297 >> Do this now, type a few characters and then delete them
285 by typing <Rubout> a few times. Don't worry about this file 298 by typing <Delete> a few times. Don't worry about this file
286 being changed; you won't affect the master tutorial. This is just 299 being changed; you won't affect the master tutorial. This is just
287 a copy of it. 300 a copy of it.
288 301
289 >> Now start typing text until you reach the right margin, and keep 302 >> Now start typing text until you reach the right margin, and keep
290 typing. When a line of text gets too big for one line on the 303 typing. When a line of text gets too big for one line on the
291 screen, the line of text is "continued" onto a second screen line. 304 screen, the line of text is "continued" onto a second screen line.
292 The backslash at the right margin indicates a line which has 305 The backslash at the right margin indicates a line which has
293 been continued. 306 been continued.
294 >> Use <Rubout>s to delete the text until the line fits on one screen 307 >> Use <Delete>s to delete the text until the line fits on one screen
295 line again. The continuation line goes away. 308 line again. The continuation line goes away.
296 309
297 >> Move the cursor to the beginning of a line and type <Rubout>. This 310 >> Move the cursor to the beginning of a line and type <Delete>. This
298 deletes the newline before the line and merges the line onto 311 deletes the newline before the line and merges the line onto
299 the previous line. The resulting line may be too long to fit, in 312 the previous line. The resulting line may be too long to fit, in
300 which case it has a continuation line. 313 which case it has a continuation line.
301 >> Type <Return> to reinsert the Newline you deleted. 314 >> Type <Return> to reinsert the Newline you deleted.
302 315
307 320
308 You've now learned the most basic way of typing something in 321 You've now learned the most basic way of typing something in
309 Emacs and correcting errors. You can delete by words or lines 322 Emacs and correcting errors. You can delete by words or lines
310 as well. Here is a summary of the delete operations: 323 as well. Here is a summary of the delete operations:
311 324
312 <Rubout> delete the character just before the cursor 325 <Delete> delete the character just before the cursor
313 C-d delete the next character after the cursor 326 C-d delete the next character after the cursor
314 327
315 M-<Rubout> kill the word immediately before the cursor 328 M-<Delete> kill the word immediately before the cursor
316 M-d kill the next word after the cursor 329 M-d kill the next word after the cursor
317 330
318 C-k kill from the cursor position to end of line 331 C-k kill from the cursor position to end of line
319 M-k kill to the end of the current sentence 332 M-k kill to the end of the current sentence
320 333
321 Notice that <Rubout> and C-d vs M-<Rubout> and M-d extend the parallel 334 Notice that <Delete> and C-d vs M-<Delete> and M-d extend the parallel
322 started by C-f and M-f (well, <Rubout> isn't really a control 335 started by C-f and M-f (well, <Delete> isn't really a control
323 character, but let's not worry about that). C-k and M-k are like C-e 336 character, but let's not worry about that). C-k and M-k are like C-e
324 and M-e, sort of, in that lines are opposite sentences. 337 and M-e, sort of, in that lines are opposite sentences.
325 338
326 Now suppose you kill something, and then you decide that you want to 339 Now suppose you kill something, and then you decide that you want to
327 get it back? Well, whenever you kill something bigger than a 340 get it back? Well, whenever you kill something bigger than a
332 can be yanked back, and "Deleted" things cannot. Generally, the 345 can be yanked back, and "Deleted" things cannot. Generally, the
333 commands that can destroy a lot of text save it, while the ones that 346 commands that can destroy a lot of text save it, while the ones that
334 attack only one character, or nothing but blank lines and spaces, do 347 attack only one character, or nothing but blank lines and spaces, do
335 not save. 348 not save.
336 349
337 For instance, type C-n a couple times to postion the cursor 350 For instance, type C-n a couple times to position the cursor
338 at some line on this screen. 351 at some line on this screen.
339 352
340 >> Do this now, move the cursor and kill that line with C-k. 353 >> Do this now, move the cursor and kill that line with C-k.
341 354
342 Note that a single C-k kills the contents of the line, and a second 355 Note that a single C-k kills the contents of the line, and a second
379 the second kill line comes back, and then a few more. 392 the second kill line comes back, and then a few more.
380 If you like, you can try giving M-y positive and negative 393 If you like, you can try giving M-y positive and negative
381 arguments. 394 arguments.
382 395
383 396
384 UNDO 397 * UNDO
385 ---- 398 ------
386 399
387 Any time you make a change to the text and wish you had not done so, 400 Any time you make a change to the text and wish you had not done so,
388 you can undo the change (return the text to its previous state) 401 you can undo the change (return the text to its previous state)
389 with the undo command, C-x u. Normally, C-x u undoes one command's 402 with the undo command, C-x u. Normally, C-x u undoes one command's
390 worth of changes; if you repeat the C-x u several times in a row, 403 worth of changes; if you repeat the C-x u several times in a row,
404 417
405 Giving a numeric argument to C-_ or C-x u is equivalent to repeating 418 Giving a numeric argument to C-_ or C-x u is equivalent to repeating
406 it as many times as the argument says. 419 it as many times as the argument says.
407 420
408 421
409 FILES 422 * FILES
410 ----- 423 -------
411 424
412 In order to make the text you edit permanent, you must put it in a 425 In order to make the text you edit permanent, you must put it in a
413 file. Otherwise, it will go away when your invocation of Emacs goes 426 file. Otherwise, it will go away when your invocation of Emacs goes
414 away. You put your editing in a file by "finding" the file. What 427 away. You put your editing in a file by "finding" the file. What
415 finding means is that you see the contents of the file in your Emacs; 428 finding means is that you see the contents of the file in your Emacs;
466 479
467 >> Type C-x C-s, saving your copy of the tutorial. 480 >> Type C-x C-s, saving your copy of the tutorial.
468 This should print "Wrote .../TUTORIAL" at the bottom of the screen. 481 This should print "Wrote .../TUTORIAL" at the bottom of the screen.
469 On VMS it will print "Wrote ...[...]TUTORIAL." 482 On VMS it will print "Wrote ...[...]TUTORIAL."
470 483
484 NOTE: On some systems, typing C-x C-s will freeze the screen and you
485 will see no further output from Emacs. This indicates that an
486 operating system "feature" called "flow control" is intercepting the
487 C-s and not letting it get through to Emacs. To unfreeze the screen,
488 type C-q. Then see the section "Spontaneous Entry to Incremental
489 Search" in the Emacs manual for advice on dealing with this "feature".
490
471 To make a new file, just find it "as if" it already existed. Then 491 To make a new file, just find it "as if" it already existed. Then
472 start typing in the text. When you ask to "save" the file, Emacs 492 start typing in the text. When you ask to "save" the file, Emacs
473 will really create the file with the text that you have inserted. 493 will really create the file with the text that you have inserted.
474 From then on, you can consider yourself to be editing an already 494 From then on, you can consider yourself to be editing an already
475 existing file. 495 existing file.
476 496
477 497
478 BUFFERS 498 * BUFFERS
479 ------- 499 ---------
480 500
481 If you find a second file with C-x C-f, the first file remains 501 If you find a second file with C-x C-f, the first file remains
482 inside Emacs. You can switch back to it by finding it again with 502 inside Emacs. You can switch back to it by finding it again with
483 C-x C-f. This way you can get quite a number of files inside Emacs. 503 C-x C-f. This way you can get quite a number of files inside Emacs.
484 504
512 C-x s goes through the list of all the buffers you have 532 C-x s goes through the list of all the buffers you have
513 and finds the ones that contain files you have changed. 533 and finds the ones that contain files you have changed.
514 For each such buffer, C-x s asks you whether to save it. 534 For each such buffer, C-x s asks you whether to save it.
515 535
516 536
517 USING THE MENU 537 * USING THE MENU
518 -------------- 538 ----------------
519 539
520 If you are on an X terminal, you will notice a menubar at the 540 If you are on an X terminal, you will notice a menubar at the
521 top of the Emacs screen. You can use this menubar to access all 541 top of the Emacs screen. You can use this menubar to access all
522 the most common Emacs commands, such as "find file". You will 542 the most common Emacs commands, such as "find file". You will
523 find this easier at first, because you don't need to remember 543 find this easier at first, because you don't need to remember
532 of the available buffers in most-recently used order. You can 552 of the available buffers in most-recently used order. You can
533 switch to any buffer by simply findings its name in the Buffers 553 switch to any buffer by simply findings its name in the Buffers
534 menu and selecting it. 554 menu and selecting it.
535 555
536 556
537 USING THE MOUSE 557 * USING THE MOUSE
538 --------------- 558 -----------------
539 559
540 When running under X, Emacs is fully integrated with the mouse. 560 When running under X, Emacs is fully integrated with the mouse.
541 You can position the text cursor by clicking the left button at 561 You can position the text cursor by clicking the left button at
542 the desired location, and you can select text by dragging the 562 the desired location, and you can select text by dragging the
543 left mouse button across the text you want to select. (Or 563 left mouse button across the text you want to select. (Or
573 593
574 You will have to hold the button down in order to keep the 594 You will have to hold the button down in order to keep the
575 menu up. 595 menu up.
576 596
577 597
578 EXTENDING THE COMMAND SET 598 * EXTENDING THE COMMAND SET
579 ------------------------- 599 ---------------------------
580 600
581 There are many, many more Emacs commands than could possibly be put 601 There are many, many more Emacs commands than could possibly be put
582 on all the control and meta characters. Emacs gets around this with 602 on all the control and meta characters. Emacs gets around this with
583 the X (eXtend) command. This comes in two flavors: 603 the X (eXtend) command. This comes in two flavors:
584 604
591 Another example is the command to tell Emacs that you'd like to stop 611 Another example is the command to tell Emacs that you'd like to stop
592 editing and get rid of Emacs. The command to do this is C-x C-c. 612 editing and get rid of Emacs. The command to do this is C-x C-c.
593 (Don't worry; it offers to save each changed file before it kills the 613 (Don't worry; it offers to save each changed file before it kills the
594 Emacs.) 614 Emacs.)
595 615
596 C-z is the usual way to exit Emacs, because it is always better not to 616 C-z is the command to exit Emacs *temporarily*--so that you can go
597 kill the Emacs if you are going to do any more editing. On systems 617 back to the same Emacs session afterward.
598 which allow it, C-z exits from Emacs to the shell but does not destroy 618
599 the Emacs; if you use the C shell, you can resume Emacs with the `fg' 619 On systems which allow it, C-z exits from Emacs to the shell but does
600 command (or, more generally, with `%emacs', which works even if your 620 not destroy the Emacs; if you use the C shell, you can resume Emacs
601 most recent job was some other). On systems where suspending is not 621 with the `fg' command (or, more generally, with `%emacs', which works
602 possible, C-z creates a subshell running under Emacs to give you the 622 even if your most recent job was some other). On systems which don't
603 chance to run other programs and return to Emacs afterward, but it 623 implement suspending, C-z creates a subshell running under Emacs to
604 does not truly "exit" from Emacs. In this case, the shell command 624 give you the chance to run other programs and return to Emacs
605 `exit' is the usual way to get back to Emacs from the subshell. 625 afterward; it does not truly "exit" from Emacs. In this case, the
606 626 shell command `exit' is the usual way to get back to Emacs from the
607 You would use C-x C-c if you were about to log out. You would 627 subshell.
608 also use it to exit an Emacs invoked under mail handling programs 628
609 and other random utilities, since they may not believe you have 629 The time to use C-x C-c is when you are about to log out. It's also
610 really finished using the Emacs if it continues to exist. 630 the right thing to use to exit an Emacs invoked under mail handling
631 programs and other random utilities, since they may not know how to
632 cope with suspension of Emacs. On other occasions, use C-z, and
633 resume the Emacs when you have more editing to do.
611 634
612 There are many C-x commands. The ones you know are: 635 There are many C-x commands. The ones you know are:
613 636
614 C-x C-f Find file. 637 C-x C-f Find file.
615 C-x C-s Save file. 638 C-x C-s Save file.
630 653
631 >> Move the cursor to the blank line two lines below this one. 654 >> Move the cursor to the blank line two lines below this one.
632 Then type M-x repl s<Return>changed<Return>altered<Return>. 655 Then type M-x repl s<Return>changed<Return>altered<Return>.
633 656
634 Notice how this line has changed: you've replaced 657 Notice how this line has changed: you've replaced
635 the word c-h-a-n-g-e-d with "altered" wherever it occured 658 the word c-h-a-n-g-e-d with "altered" wherever it occurred
636 after the cursor. 659 after the cursor.
637 660
638 661
639 MODE LINE 662 * AUTO SAVE
640 --------- 663 -----------
664
665 When you have made changes in a file, but you have not saved them yet,
666 they could be lost if your computer crashes. To protect you from
667 this, Emacs writes "auto save" files periodically. The auto save file
668 name has a # at the beginning and the end; for example, if your file
669 is named "hello.c", its auto save file's name is "#hello.c#". When
670 you save the file in the normal way, its auto save file is no longer
671 necessary so Emacs deletes it.
672
673 If the computer crashes, you can recover your auto-saved editing by
674 finding the file normally (the file you were editing, not the auto
675 save file) and then typing M-x recover file<return>. When it asks for
676 confirmation, type yes<return> to go ahead and recover the auto-save
677 data.
678
679
680 * MODE LINE
681 -----------
641 682
642 If Emacs sees that you are typing commands slowly it shows them to you 683 If Emacs sees that you are typing commands slowly it shows them to you
643 at the bottom of the screen in an area called the "echo area." The echo 684 at the bottom of the screen in an area called the "echo area." The echo
644 area contains the bottom line of the screen. The line immediately above 685 area contains the bottom line of the screen. The line immediately above
645 it is called the MODE LINE. The mode line says something like 686 it is called the MODE LINE. The mode line says something like
668 differently. For example, there are commands for creating comments in 709 differently. For example, there are commands for creating comments in
669 a program, and since each programming language has a different idea of 710 a program, and since each programming language has a different idea of
670 what a comment should look like, each major mode has to insert 711 what a comment should look like, each major mode has to insert
671 comments differently. Each major mode is the name of an extended 712 comments differently. Each major mode is the name of an extended
672 command, which is how you get into the mode. For example, 713 command, which is how you get into the mode. For example,
673 M-X fundamental-mode is how to get into Fundamental mode. 714 M-x fundamental-mode is how to get into Fundamental mode.
674 715
675 If you are going to be editing English text, such as this file, you 716 If you are going to be editing English text, such as this file, you
676 should probably use Text Mode. 717 should probably use Text Mode.
677 >> Type M-x text-mode<Return>. 718 >> Type M-x text-mode<Return>.
678 719
679 Don't worry, none of the commands you have learned changes Emacs in 720 Don't worry, none of the commands you have learned changes Emacs in
680 any great way. But you can now observe that periods are no longer 721 any great way. But you can observe that apostrophes are now part of
681 part of words when you do M-f or M-b! Major modes are usually like 722 words when you do M-f or M-b. Major modes are usually like that:
682 that: commands don't change into completely unrelated things, but they 723 commands don't change into completely unrelated things, but they work
683 work a little bit differently. 724 a little bit differently.
684 725
685 To get documentation on your current major mode, type C-h m. 726 To get documentation on your current major mode, type C-h m.
686 727
687 >> Use C-u C-v once or more to bring this line near the top of screen. 728 >> Use C-u C-v once or more to bring this line near the top of screen.
688 >> Type C-h m, to see how Text mode differs from Fundamental mode. 729 >> Type C-h m, to see how Text mode differs from Fundamental mode.
722 that paragraph. 763 that paragraph.
723 764
724 >> Move the cursor into the previous paragraph and type M-q. 765 >> Move the cursor into the previous paragraph and type M-q.
725 766
726 767
727 SEARCHING 768 * SEARCHING
728 --------- 769 -----------
729 770
730 Emacs can do searches for strings (these are groups of contiguous 771 Emacs can do searches for strings (these are groups of contiguous
731 characters or words) either forward through the file or backward 772 characters or words) either forward through the file or backward
732 through it. To search for the string means that you are trying to 773 through it. To search for the string means that you are trying to
733 locate it somewhere in the file and have Emacs show you where the 774 locate it somewhere in the file and have Emacs show you where the
737 initiate a search is C-s for forward search, and C-r for reverse 778 initiate a search is C-s for forward search, and C-r for reverse
738 search. BUT WAIT! Don't do them now. When you type C-s you'll 779 search. BUT WAIT! Don't do them now. When you type C-s you'll
739 notice that the string "I-search" appears as a prompt in the echo 780 notice that the string "I-search" appears as a prompt in the echo
740 area. This tells you that Emacs is in what is called an incremental 781 area. This tells you that Emacs is in what is called an incremental
741 search waiting for you to type the thing that you want to search for. 782 search waiting for you to type the thing that you want to search for.
742 <ESC> terminates a search. 783 <RET> terminates a search.
743 784
744 >> Now type C-s to start a search. SLOWLY, one letter at a time, 785 >> Now type C-s to start a search. SLOWLY, one letter at a time,
745 type the word 'cursor', pausing after you type each 786 type the word 'cursor', pausing after you type each
746 character to notice what happens to the cursor. 787 character to notice what happens to the cursor.
747 >> Type C-s to find the next occurrence of "cursor". 788 >> Type C-s to find the next occurrence of "cursor".
748 >> Now type <Rubout> four times and see how the cursor moves. 789 >> Now type <Delete> four times and see how the cursor moves.
749 >> Type <ESC> to terminate the search. 790 >> Type <RET> to terminate the search.
750 791
751 Did you see what happened? Emacs, in an incremental search, tries to 792 Did you see what happened? Emacs, in an incremental search, tries to
752 go to the occurrence of the string that you've typed out so far. To go 793 go to the occurrence of the string that you've typed out so far. To go
753 to the next occurrence of 'cursor' just type C-s again. If no such 794 to the next occurrence of 'cursor' just type C-s again. If no such
754 occurrence exists Emacs beeps and tells you that it is a failing 795 occurrence exists Emacs beeps and tells you that it is a failing
755 search. C-g would also terminate the search. 796 search. C-g would also terminate the search.
756 797
757 If you are in the middle of an incremental search and type <Rubout>, 798 NOTE: On some systems, typing C-s will freeze the screen and you will
799 see no further output from Emacs. This indicates that an operating
800 system "feature" called "flow control" is intercepting the C-s and not
801 letting it get through to Emacs. To unfreeze the screen, type C-q.
802 Then see the section "Spontaneous Entry to Incremental Search" in the
803 Emacs manual for advice on dealing with this "feature".
804
805 If you are in the middle of an incremental search and type <Delete>,
758 you'll notice that the last character in the search string is erased 806 you'll notice that the last character in the search string is erased
759 and the search backs up to the last place of the search. For 807 and the search backs up to the last place of the search. For
760 instance, suppose you currently have typed 'cu' and you see that your 808 instance, suppose you currently have typed 'cu' and you see that your
761 cursor is at the first occurrence of 'cu'. If you now type <Rubout>, 809 cursor is at the first occurrence of 'cu'. If you now type <Delete>,
762 the 'u' on the search line is erased and you'll be repositioned in the 810 the 'u' on the search line is erased and you'll be repositioned in the
763 text to the occurrence of 'c' where the search took you before you 811 text to the occurrence of 'c' where the search took you before you
764 typed the 'u'. This provides a useful means for backing up while you 812 typed the 'u'. This provides a useful means for backing up while you
765 are searching. 813 are searching.
766 814
767 If you are in the middle of a search and happen to type a control 815 If you are in the middle of a search and type a control or meta
768 character (other than a C-s or C-r, which tell Emacs to search for the 816 character (with a few exceptions--characters that are special in
769 next occurrence of the string), the search is terminated. 817 a search, such as C-s and C-r), the search is terminated.
770 818
771 The C-s starts a search that looks for any occurrence of the search 819 The C-s starts a search that looks for any occurrence of the search
772 string AFTER the current cursor position. But what if you want to 820 string AFTER the current cursor position. But what if you want to
773 search for something earlier in the text? To do this, type C-r for 821 search for something earlier in the text? To do this, type C-r for
774 Reverse search. Everything that applies to C-s applies to C-r except 822 Reverse search. Everything that applies to C-s applies to C-r except
775 that the direction of the search is reversed. 823 that the direction of the search is reversed.
776 824
777 825
778 RECURSIVE EDITING LEVELS 826 * MULTIPLE WINDOWS
779 ------------------------ 827 ------------------
828
829 One of the nice features of Emacs is that you can display more than one
830 window on the screen at the same time.
831
832 >> Move the cursor to this line and type C-u 0 C-l.
833
834 >> Now type C-x 2 which splits the screen into two windows.
835 Both windows display this tutorial. The cursor stays in the top window.
836
837 >> Type C-M-v to scroll the bottom window.
838 (If you don't have a real Meta key, type ESC C-v.)
839
840 >> Type C-x o ("o" for "other") to move the cursor to the bottom window.
841 >> Use C-v and M-v in the bottom window to scroll it.
842 Keep reading these directions in the top window.
843
844 >> Type C-x o again to move the cursor back to the top window.
845 The cursor is still just where it was in the top window before.
846
847 You can keep using C-x o to switch between the windows. Each
848 window has its own cursor position, but only one window actually
849 shows the cursor. All the ordinary editing commands apply to the
850 window that the cursor is in.
851
852 The command C-M-v is very useful when you are editing text in one
853 window and using the other window just for reference. You can keep
854 the cursor always in the window where you are editing, and edit
855 there as you advance through the other window.
856
857 C-M-v is an example of a CONTROL-META character. If you have a real
858 META key, you can type C-M-v by holding down both CTRL and META while
859 typing v.
860
861 It doesn't matter whether CTRL or META "comes first," because both of
862 these keys act by modifying the characters you type. But if you don't
863 have a real META key, and you use ESC instead, the order does matter:
864 you must type ESC followed by CTRL-v; CTRL-ESC v will not work. This
865 is because ESC is a character in its own right, not a modifier key.
866
867 >> Type C-x 1 (in the top window) to get rid of the bottom window.
868
869 (If you had typed C-x 1 in the bottom window, that would get rid
870 of the top one. Think of this command as "Keep just one
871 window--the window I am already in.")
872
873 You don't have to display the same buffer in both windows. If
874 you use C-x C-f to find a file in one window, the other window
875 doesn't change. You can pick a file in each window
876 independently.
877
878 Here is another way to use two windows to display two different
879 things:
880
881 >> Type C-x 4 C-f followed by the name of one of your files.
882 End with <RETURN>. See the specified file appear in the bottom
883 window. The cursor goes there, too.
884
885 >> Type C-x o to go back to the top window, and C-x 1 to delete
886 the bottom window.
887
888
889 * RECURSIVE EDITING LEVELS
890 --------------------------
780 891
781 Sometimes you will get into what is called a "recursive editing 892 Sometimes you will get into what is called a "recursive editing
782 level". This is indicated by square brackets in the mode line, 893 level". This is indicated by square brackets in the mode line,
783 surrounding the parentheses around the major mode name. For 894 surrounding the parentheses around the major mode name. For
784 example, you might see [(Fundamental)] instead of (Fundamental). 895 example, you might see [(Fundamental)] instead of (Fundamental).
785 896
786 To get out of the recursive editing level, type 897 To get out of the recursive editing level, type ESC ESC ESC. That is
787 M-x top-level<Return>. 898 an all-purpose "get out" command. You can also use it for eliminating
788 899 extra windows, and getting out of the minibuffer.
789 >> Try that now; it should display "Back to top level" 900
790 at the bottom of the screen. 901 >> Type M-x to get into a minibuffer; then type ESC ESC ESC to get out.
791
792 In fact, you were ALREADY at top level (not inside a recursive editing
793 level) if you have obeyed instructions. M-x top-level does not care;
794 it gets out of any number of recursive editing levels, perhaps zero,
795 to get back to top level.
796 902
797 You can't use C-g to get out of a recursive editing level because C-g 903 You can't use C-g to get out of a recursive editing level because C-g
798 is used for discarding numeric arguments and partially typed commands 904 is used for canceling commands and arguments WITHIN the recursive
799 WITHIN the recursive editing level. 905 editing level.
800 906
801 907
802 GETTING MORE HELP 908 * GETTING MORE HELP
803 ----------------- 909 -------------------
804 910
805 In this tutorial we have tried to supply just enough information to 911 In this tutorial we have tried to supply just enough information to
806 get you started using Emacs. There is so much available in Emacs that 912 get you started using Emacs. There is so much available in Emacs that
807 it would be impossible to explain it all here. However, you may want 913 it would be impossible to explain it all here. However, you may want
808 to learn more about Emacs since it has numerous desirable features 914 to learn more about Emacs since it has numerous desirable features
813 919
814 To use the HELP features, type the C-h character, and then a 920 To use the HELP features, type the C-h character, and then a
815 character saying what kind of help you want. If you are REALLY lost, 921 character saying what kind of help you want. If you are REALLY lost,
816 type C-h ? and Emacs will tell you what kinds of help it can give. 922 type C-h ? and Emacs will tell you what kinds of help it can give.
817 If you have typed C-h and decide you don't want any help, just 923 If you have typed C-h and decide you don't want any help, just
818 type C-G to cancel it. 924 type C-g to cancel it.
819 925
820 The most basic HELP feature is C-h c. Type C-h, a c, and a 926 The most basic HELP feature is C-h c. Type C-h, a c, and a
821 command character or sequence, and Emacs displays a very brief 927 command character or sequence, and Emacs displays a very brief
822 description of the command. 928 description of the command.
823 929
836 942
837 To get more information on the command, use C-h k instead of C-h c. 943 To get more information on the command, use C-h k instead of C-h c.
838 944
839 >> Type C-h k Control-p. 945 >> Type C-h k Control-p.
840 946
841 This displays the documentation of the function, as well as its name, 947 This displays the documentation of the function, as well as its
842 in an Emacs window. When you are finished reading the output, type 948 name, in an Emacs window. When you are finished reading the
843 C-x 1 to get rid of the help text. You do not have to do this right 949 output, type C-x 1 to get rid of the help text. You do not have
844 away. You can do some editing based on the help text before you type 950 to do this right away. You can do some editing while referring
845 C-x 1. 951 to the help text and then type C-x 1.
846 952
847 Here are some other useful C-h options: 953 Here are some other useful C-h options:
848 954
849 C-h f Describe a function. You type in the name of the 955 C-h f Describe a function. You type in the name of the
850 function. 956 function.
851 957
852 >> Try typing C-h f previous-line<Return>. 958 >> Try typing C-h f previous-line<Return>.
853 This prints all the information Emacs has about the 959 This prints all the information Emacs has about the
854 function which implements the C-P command. 960 function which implements the C-p command.
855 961
856 C-h a Command Apropos. Type in a keyword and Emacs will list 962 C-h a Command Apropos. Type in a keyword and Emacs will list
857 all the commands whose names contain that keyword. 963 all the commands whose names contain that keyword.
858 These commands can all be invoked with Meta-x. 964 These commands can all be invoked with Meta-x.
859 For some commands, Command Apropos will also list a one 965 For some commands, Command Apropos will also list a one
860 or two character sequence which has the same effect. 966 or two character sequence which has the same effect.
861 967
862 >> Type C-h a file<Return>. You will see a list of all M-x commands 968 >> Type C-h a file<Return>.
863 with "file" in their names. You will also see commands 969
864 like C-x C-f and C-x C-w, listed beside the command names 970 This displays in another window a list of all M-x commands with
865 find-file and write-file. 971 "file" in their names. You will also see commands like C-x C-f
866 972 and C-x C-w, listed beside the command names find-file and
867 973 write-file.
868 CONCLUSION 974
869 ---------- 975 >> Type C-M-v to scroll the help window. Do this a few times.
976
977 >> Type C-x 1 to delete the help window.
978
979
980 * CONCLUSION
981 ------------
870 982
871 Remember, to exit Emacs permanently use C-x C-c. To exit to a shell 983 Remember, to exit Emacs permanently use C-x C-c. To exit to a shell
872 temporarily, so that you can come back in, use C-z. (This does not 984 temporarily, so that you can come back in, use C-z. (This does not
873 work under X windows, because there is no real concept of exiting 985 work under X windows, because there is no real concept of exiting
874 temporarily to the shell. Instead, C-z iconifies the Emacs screen.) 986 temporarily to the shell. Instead, C-z iconifies the Emacs screen.)
880 COPYING 992 COPYING
881 ------- 993 -------
882 994
883 This tutorial descends from a long line of Emacs tutorials 995 This tutorial descends from a long line of Emacs tutorials
884 starting with the one written by Stuart Cracraft for the original Emacs. 996 starting with the one written by Stuart Cracraft for the original Emacs.
885 It was last modified September 1994 by Ben Wing, who updated the 997 Ben Wing updated the tutorial for X Windows.
886 tutorial for X.
887 998
888 This version of the tutorial, like GNU Emacs, is copyrighted, and 999 This version of the tutorial, like GNU Emacs, is copyrighted, and
889 comes with permission to distribute copies on certain conditions: 1000 comes with permission to distribute copies on certain conditions:
890 1001
891 Copyright (c) 1985, 1994 Free Software Foundation 1002 Copyright (c) 1985, 1996 Free Software Foundation
892 1003
893 Permission is granted to anyone to make or distribute verbatim copies 1004 Permission is granted to anyone to make or distribute verbatim copies
894 of this document as received, in any medium, provided that the 1005 of this document as received, in any medium, provided that the
895 copyright notice and permission notice are preserved, 1006 copyright notice and permission notice are preserved,
896 and that the distributor grants the recipient permission 1007 and that the distributor grants the recipient permission