📄 tutorial
字号:
MODE LINE---------If Emacs sees that you are typing commands slowly it shows them to youat the bottom of the screen in an area called the "echo area." The echoarea contains the bottom line of the screen. The line immediately aboveit is called the MODE LINE. The mode line says something like--**--Emacs: TUTORIAL (Fundamental)----58%-------------This is a very useful "information" line.You already know what the filename means--it is the file you havefound. What the --NN%-- means is that NN percent of the file isabove the top of the screen. If the top of the file is on the screen,it will say --TOP-- instead of --00%--. If the bottom of the file ison the screen, it will say --BOT--. If you are looking at a file sosmall it all fits on the screen, it says --ALL--.The stars near the front mean that you have made changes to the text.Right after you visit or save a file, there are no stars, just dashes.The part of the mode line inside the parentheses is to tell you whatmodes you are in. The default mode is Fundamental which is what youare in now. It is an example of a "major mode". There are severalmajor modes in Emacs for editing different languages and text, such asLisp mode, Text mode, etc. At any time one and only one major mode isactive, and its name can always be found in the mode line just where"Fundamental" is now. Each major mode makes a few commands behavedifferently. For example, there are commands for creating comments ina program, and since each programming language has a different idea ofwhat a comment should look like, each major mode has to insertcomments differently. Each major mode is the name of an extendedcommand, which is how you get into the mode. For example,M-X fundamental-mode is how to get into Fundamental mode.If you are going to be editing English text, such as this file, youshould probably use Text Mode.>> Type M-x text-mode<Return>.Don't worry, none of the commands you have learned changes Emacs inany great way. But you can now observe that periods are no longerpart of words when you do M-f or M-b! Major modes are usually likethat: commands don't change into completely unrelated things, but theywork a little bit differently.To get documentation on your current major mode, type C-h m.>> Use C-u C-v once or more to bring this line near the top of screen.>> Type C-h m, to see how Text mode differs from Fundamental mode.>> Type C-x 1 to remove the documentation from the screen.Major modes are called major because there are also minor modes.They are called minor because they aren't alternatives to the majormodes, just minor modifications of them. Each minor mode can beturned on or off by itself, regardless of what major mode you are in,and regardless of the other minor modes. So you can use no minormodes, or one minor mode, or any combination of several minor modes.One minor mode which is very useful, especially for editing Englishtext, is Auto Fill mode. When this mode is on, Emacs breaks the linein between words automatically whenever the line gets too long. Youcan turn this mode on by doing M-x auto-fill-mode<Return>. When themode is on, you can turn it off by doing M-x auto-fill-mode<Return>.If the mode is off, this function turns it on, and if the mode is on,this function turns it off. This is called "toggling".>> Type M-x auto-fill-mode<Return> now. Then insert a line of "asdf " over again until you see it divide into two lines. You must put in spaces between them because Auto Fill breaks lines only at spaces.The margin is usually set at 70 characters, but you can change itwith the C-x f command. You should give the margin setting you wantas a numeric argument.>> Type C-x f with an argument of 20. (C-u 2 0 C-x f). Then type in some text and see Emacs fill lines of 20 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 modedoes not re-fill it for you.To re-fill the paragraph, type M-q (Meta-q) with the cursor insidethat paragraph.>> Move the cursor into the previous paragraph and type M-q.SEARCHING---------Emacs can do searches for strings (these are groups of contiguouscharacters or words) either forward through the file or backwardthrough it. To search for the string means that you are trying tolocate it somewhere in the file and have Emacs show you where theoccurrences of the string exist. This type of search is somewhatdifferent from what you may be familiar with. It is a search that isperformed as you type in the thing to search for. The command toinitiate a search is C-s for forward search, and C-r for reversesearch. BUT WAIT! Don't do them now. When you type C-s you'llnotice that the string "I-search" appears as a prompt in the echoarea. This tells you that Emacs is in what is called an incrementalsearch waiting for you to type the thing that you want to search for.<ESC> 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.>> Type C-s to find the next occurrence of "cursor".>> Now type <Rubout> four times and see how the cursor moves.>> Type <ESC> 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. To goto the next occurrence of 'cursor' just type C-s again. If no suchoccurrence exists Emacs beeps and tells you that it is a failingsearch. C-g would also terminate the search.If you are in the middle of an incremental search and type <Rubout>,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 currently have typed 'cu' and you see that yourcursor is at the first occurrence of 'cu'. If you now type <Rubout>,the 'u' on the search line is erased and you'll be repositioned in thetext to the occurrence of 'c' where the search took you before youtyped the 'u'. This provides a useful means for backing up while youare searching.If you are in the middle of a search and happen to type a controlcharacter (other than a C-s or C-r, which tell Emacs to search for thenext occurrence of the string), the search is terminated.The C-s starts a search that looks for any occurrence of the searchstring AFTER the current cursor position. But what if you want tosearch for something earlier in the text? To do this, type C-r forReverse search. Everything that applies to C-s applies to C-r exceptthat the direction of the search is reversed.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 M-x top-level<Return>.>> Try that now; it should display "Back to top level" at the bottom of the screen.In fact, you were ALREADY at top level (not inside a recursive editinglevel) if you have obeyed instructions. M-x top-level does not care;it gets out of any number of recursive editing levels, perhaps zero,to get back to top level.You can't use C-g to get out of a recursive editing level because C-gis used for discarding numeric arguments and partially typed commandsWITHIN the recursive 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 numerous desirable featuresthat you don't know about yet. Emacs has a great deal of internaldocumentation. All of these commands can be accessed throughthe character Control-h, which we call "the Help character"because of the function it serves.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 don't want any help, justtype C-G to cancel it.The most basic HELP feature is C-h c. Type C-h, a c, and acommand character or sequence, and Emacs displays a very briefdescription of the command.>> Type C-h c Control-p. The message should be something like C-p runs the command previous-lineThis tells you the "name of the function". That is important inwriting Lisp code to extend Emacs; it also is enough to remindyou of what the command does if you have seen it before but didnot remember.Multi-character commands such as C-x C-s and (if you have no META orEDIT key) <ESC>v are also allowed after C-h c.To get more information on the command, use C-h k instead of C-h c.>> Type C-h k Control-p.This displays the documentation of the function, as well as its name,in an Emacs window. When you are finished reading the output, typeC-x 1 to get rid of the help text. You do not have to do this rightaway. You can do some editing based on the help text before you typeC-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 prints all the information Emacs has about the function which implements the C-P command. 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 has the same effect.>> Type C-h a file<Return>. You will see a list of all M-x commandswith "file" in their names. You will also see commandslike C-x C-f and C-x C-w, listed beside the command namesfind-file and write-file.CONCLUSION----------Remember, to exit Emacs permanently use C-x C-c. To exit to a shelltemporarily, so that you can come back in, 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 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 slightly differentbut in the same spirit. Please read the file COPYING and thendo give copies of GNU 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 + -