📄 tutorial
字号:
When you type C-s you'll notice that the string "I-search" appears asa prompt in the echo area. This tells you that Emacs is in what iscalled an incremental search waiting for you to type the thing thatyou want to search for. <Return> terminates a search.>> Now type C-s to start a search. SLOWLY, one letter at a time, type the word 'cursor', pausing after you type each character to notice what happens to the cursor. Now you have searched for "cursor", once.>> Type C-s again, to search for the next occurrence of "cursor".>> Now type <Delback> four times and see how the cursor moves.>> Type <Return> to terminate the search.Did you see what happened? Emacs, in an incremental search, tries togo to the occurrence of the string that you've typed out so far. Togo to the next occurrence of 'cursor' just type C-s again. If no suchoccurrence 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 willsee no further output from Emacs. This indicates that an operatingsystem "feature" called "flow control" is intercepting the C-s and notletting it get through to Emacs. To unfreeze the screen, type C-q.Then see the section "Spontaneous Entry to Incremental Search" in theEmacs manual for advice on dealing with this "feature".If you are in the middle of an incremental search and type <Delback>,you'll notice that the last character in the search string is erasedand the search backs up to the last place of the search. Forinstance, suppose you have typed "c", to search for the firstoccurrence of "c". Now if you type "u", the cursor will moveto the first occurrence of "cu". Now type <Delback>. This erasesthe "u" from the search string, and the cursor moves back tothe first occurrence of "c".If you are in the middle of a search and type a control or metacharacter (with a few exceptions--characters that are special ina search, such as C-s and C-r), the search is terminated.The C-s starts a search that looks for any occurrence of the searchstring AFTER the current cursor position. If you want to search forsomething earlier in the text, type C-r instead. Everything that wehave said about C-s also applies to C-r, except that the direction ofthe search is reversed.* MULTIPLE WINDOWS------------------One of the nice features of Emacs is that you can display more than onewindow on the screen at the same time.>> 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.)>> 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. Keep reading these directions in the top window.>> Type C-x o again to move the cursor back to the top window. The cursor in the top window is just where it was before.You can keep using C-x o to switch between the windows. Eachwindow has its own cursor position, but only one window actuallyshows the cursor. All the ordinary editing commands apply to thewindow that the cursor is in. We call this the "selected window".The command C-M-v is very useful when you are editing text in onewindow and using the other window just for reference. You can keepthe cursor always in the window where you are editing, and advancethrough the other window sequentially with C-M-v.C-M-v is an example of a CONTROL-META character. If you have a realMETA key, you can type C-M-v by holding down both CONTROL and META whiletyping 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 orderdoes matter: you must type ESC followed by CONTROL-v, becauseCONTROL-ESC v will not work. This is because ESC is a character inits own right, not a modifier key.>> Type C-x 1 (in the top window) to get rid of the bottom window.(If you had typed C-x 1 in the bottom window, that would get ridof the top one. Think of this command as "Keep just onewindow--the window I am already in.")You do not have to display the same buffer in both windows. If youuse C-x C-f to find a file in one window, the other window does notchange. You can find a file in each window independently.Here is another way to use two windows to display two differentthings:>> Type C-x 4 C-f followed by the name of one of your files. End with <Return>. See the specified file appear in the bottom window. The cursor goes there, too.>> Type C-x o to go back to the top window, and C-x 1 to delete the bottom window.* RECURSIVE EDITING LEVELS--------------------------Sometimes you will get into what is called a "recursive editinglevel". This is indicated by square brackets in the mode line,surrounding the parentheses around the major mode name. Forexample, you might see [(Fundamental)] instead of (Fundamental).To get out of the recursive editing level, type ESC ESC ESC. That isan all-purpose "get out" command. You can also use it for eliminatingextra windows, and getting out of the minibuffer.>> Type M-x to get into a minibuffer; then type ESC ESC ESC to get out.You cannot use C-g to get out of a recursive editing level. This isbecause C-g is used for canceling commands and arguments WITHIN therecursive editing level.* GETTING MORE HELP-------------------In this tutorial we have tried to supply just enough information toget you started using Emacs. There is so much available in Emacs thatit would be impossible to explain it all here. However, you may wantto learn more about Emacs since it has many other useful features.Emacs provides commands for reading documentation about Emacscommands. These "help" commands all start with the characterCONTROL-h, which is called "the Help character".To use the Help features, type the C-h character, and then acharacter saying what kind of help you want. If you are REALLY lost,type C-h ? and Emacs will tell you what kinds of help it can give.If you have typed C-h and decide you do not want any help, justtype C-g to cancel it.(Some sites change the meaning of the character C-h. They reallyshould not do this as a blanket measure for all users, so you havegrounds to complain to the system administrator. Meanwhile, if C-hdoes not display a message about help at the bottom of the screen, trytyping the F1 key or M-x help <Return> instead.)The most basic HELP feature is C-h c. Type C-h, the character c, anda command character or sequence; then Emacs displays a very briefdescription of the command.>> Type C-h c C-p. The message should be something like C-p runs the command previous-lineThis tells you the "name of the function". Function names are usedmainly for customizing and extending Emacs. But since function namesare chosen to indicate what the command does, they can serve also asvery brief documentation--sufficient to remind you of commands youhave already learned.Multi-character commands such as C-x C-s and (if you have no META orEDIT 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 C-p.This displays the documentation of the function, as well as itsname, in an Emacs window. When you are finished reading theoutput, type C-x 1 to get rid of the help text. You do not haveto do this right away. You can do some editing while referringto the help text, and then type C-x 1.Here are some other useful C-h options: C-h f Describe a function. You type in the name of the function.>> Try typing C-h f previous-line<Return>. 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 whosevalues you can set to customize Emacs behavior. You need to type inthe 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. For some commands, Command Apropos will also list a one or two character sequence which runs the same command.>> Type C-h a file<Return>.This displays in another window a list of all M-x commands with "file"in their names. You will see character-commands like C-x C-f listedbeside the corresponding command names such as find-file.>> Type C-M-v to scroll the help window. Do this a few times.>> 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 bookor on-line in Info (use the Help menu or type F10 h r). Two featuresthat you may like especially are completion, which saves typing, anddired, which simplifies file handling.Completion is a way to avoid unnecessary typing. For instance, if youwant 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 candetermine from what you have already typed. Completion is describedin Info in the Emacs manual in the node called "Completion".Dired enables you to list files in a directory (and optionally itssubdirectories), move around that list, visit, rename, delete andotherwise operate on the files. Dired is described in Info in theEmacs manual in the node called "Dired".The manual also describes many other Emacs features.* CONCLUSION------------Remember, to exit Emacs permanently use C-x C-c. To exit to a shelltemporarily, so that you can come back to Emacs afterward, use C-z.This tutorial is meant to be understandable to all new users, so ifyou found something unclear, don't sit and blame yourself - complain!* COPYING---------This tutorial descends from a long line of Emacs tutorialsstarting with the one written by Stuart Cracraft for the original Emacs.This version of the tutorial, like GNU Emacs, is copyrighted, andcomes with permission to distribute copies on certain conditions:Copyright (c) 1985, 1996, 1998, 2001, 2002 Free Software Foundation Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the copyright notice and permission notice are preserved, and that the distributor grants the recipient permission for further redistribution as permitted by this notice. Permission is granted to distribute modified versions of this document, or of portions of it, under the above conditions, provided also that they carry prominent notices stating who last altered them.The conditions for copying Emacs itself are more complex, but in thesame spirit. Please read the file COPYING and then do give copies ofGNU Emacs to your friends. Help stamp out software obstructionism("ownership") by using, writing, and sharing free software!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -