⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorial

📁 windows版本的emacs
💻
📖 第 1 页 / 共 4 页
字号:
If you find a second file with C-x C-f, the first file remainsinside Emacs.  You can switch back to it by finding it again withC-x C-f.  This way you can get quite a number of files inside Emacs.>> Create a file named "foo" by typing  C-x C-f foo <Return>.   Then insert some text, edit it, and save "foo" by typing  C-x C-s.   Finally, type C-x C-f TUTORIAL <Return>   to come back to the tutorial.Emacs stores each file's text inside an object called a "buffer".Finding a file makes a new buffer inside Emacs.  To see a list of thebuffers that currently exist in your Emacs job, type	C-x C-b   List buffers>> Try C-x C-b now.See how each buffer has a name, and it may also have a file name forthe file whose contents it holds.  ANY text you see in an Emacs windowis always part of some buffer.>> Type C-x 1 to get rid of the buffer list.When you have several buffers, only one of them is "current" at anytime.  That buffer is the one you edit.  If you want to edit anotherbuffer, you need to "switch" to it.  If you want to switch to a bufferthat corresponds to a file, you can do it by visiting the file againwith 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 ofevery 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 buffernamed "*Buffer List*" does not have any file.  It is the buffer whichcontains the buffer list that you made with C-x C-b.  The buffer named"*Messages*" also does not correspond to any file; it contains themessages that have appeared on the bottom line during your Emacssession.>> 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'sbuffer has no effect on the first file's buffer.  This is very useful,but it also means that you need a convenient way to save the firstfile's buffer.  It would be a nuisance to have to switch back toit with C-x C-f in order to save it with C-x C-s.  So we have	C-x s     Save some buffersC-x s asks you about each buffer which contains changes that you havenot saved.  It asks you, for each such buffer, whether to save thebuffer.>> Insert a line of text, then type C-x s.   It should ask you whether to save the buffer named TUTORIAL.   Answer yes to the question by typing "y".* EXTENDING THE COMMAND SET---------------------------There are many, many more Emacs commands than could possibly be puton all the control and meta characters.  Emacs gets around this withthe X (eXtend) command.  This comes in two flavors:	C-x	Character eXtend.  Followed by one character.	M-x	Named command eXtend.  Followed by a long name.These are commands that are generally useful but used less than thecommands you have already learned about.  You have already seen two ofthem: the file commands C-x C-f to Find and C-x C-s to Save.  Anotherexample is the command to end the Emacs session--this is the commandC-x C-c.  (Do not worry about losing changes you have made; C-x C-coffers to save each changed file before it kills the Emacs.)C-z is the command to exit Emacs *temporarily*--so that you can goback to the same Emacs session afterward.On systems which allow it, C-z "suspends" Emacs; that is, it returnsto the shell but does not destroy the Emacs.  In the most commonshells, you can resume Emacs with the `fg' command or with `%emacs'.On systems which do not implement suspending, C-z creates a subshellrunning under Emacs to give you the chance to run other programs andreturn to Emacs afterward; it does not truly "exit" from Emacs.  Inthis case, the shell command `exit' is the usual way to get back toEmacs from the subshell.The time to use C-x C-c is when you are about to log out.  It's alsothe right thing to use to exit an Emacs invoked under mail handlingprograms and other miscellaneous utilities, since they may not knowhow to cope with suspension of Emacs.  In ordinary circumstances,though, if you are not about to log out, it is better to suspend Emacswith C-z instead of exiting Emacs.There are many C-x commands.  Here is a list of the ones you have learned:	C-x C-f		Find file.	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 lessfrequently, or commands which are used only in certain modes.  Anexample is the command replace-string, which globally replaces onestring with another.  When you type M-x, Emacs prompts you at thebottom of the screen with M-x and you should type the name of thecommand; in this case, "replace-string".  Just type "repl s<TAB>" andEmacs will complete the name.  (<TAB> is the Tab key, usually foundabove 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 bereplaced, and the string to replace it with.  You must end eachargument with <Return>.>> Move the cursor to the blank line two lines below this one.   Then type M-x repl s<Return>changed<Return>altered<Return>.   Notice how this line has changed: you've replaced   the word c-h-a-n-g-e-d with "altered" wherever it occurred,   after the initial position of the cursor.* AUTO SAVE-----------When you have made changes in a file, but you have not saved them yet,they could be lost if your computer crashes.  To protect you fromthis, Emacs periodically writes an "auto save" file for each file thatyou are editing.  The auto save file name has a # at the beginning andthe end; for example, if your file is named "hello.c", its auto savefile's name is "#hello.c#".  When you save the file in the normal way,Emacs deletes its auto save file.If the computer crashes, you can recover your auto-saved editing byfinding the file normally (the file you were editing, not the autosave file) and then typing M-x recover file<Return>.  When it asks forconfirmation, type yes<Return> to go ahead and recover the auto-savedata.* ECHO AREA-----------If Emacs sees that you are typing multicharacter commands slowly, itshows 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 is called the "mode line".The mode line says something like this:--:**  TUTORIAL          (Fundamental)--L670--58%----------------This line gives useful information about the status of Emacs andthe text you are editing.You already know what the filename means--it is the file you havefound.  -NN%-- indicates your current position in the text; it meansthat NN percent of the text is above the top of the screen.  If thetop of the file is on the screen, it will say --Top-- instead of--00%--.  If the bottom of the text is on the screen, it will say--Bot--.  If you are looking at text so small that all of it fits onthe screen, the mode line says --All--.The L and digits indicate position in another way: they give thecurrent 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 showsno stars, just dashes.The part of the mode line inside the parentheses is to tell you whatediting modes you are in.  The default mode is Fundamental which iswhat you are using now.  It is an example of a "major mode".  Emacs has many different major modes.  Some of them are meant forediting different languages and/or kinds of text, such as Lisp mode,Text mode, etc.  At any time one and only one major mode is active,and its name can always be found in the mode line just where"Fundamental" is now.Each major mode makes a few commands behave differently.  For example,there are commands for creating comments in a program, and since eachprogramming language has a different idea of what a comment shouldlook like, each major mode has to insert comments differently.  Eachmajor mode is the name of an extended command, which is how you canswitch to that mode.  For example, M-x fundamental-mode is a command toswitch to Fundamental mode.If you are going to be editing human-language text, such as this file, youshould probably use Text Mode.>> Type M-x text mode<Return>.Don't worry, none of the  Emacs commands you have learned changes inany great way.  But you can observe that M-f and M-b now treatapostrophes as part of words.  Previously, in Fundamental mode,M-f and M-b treated apostrophes as word-separators.Major modes usually make subtle changes like that one: most commandsdo "the same job" in each major mode, but they work a little bitdifferently.To view 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.Minor modes are not alternatives to the major modes, just minormodifications of them.  Each minor mode can be turned on or off byitself, independent of all other minor modes, and independent of yourmajor mode.  So you can use no minor modes, or one minor mode, or anycombination of several minor modes.One minor mode which is very useful, especially for editinghuman-language text, is Auto Fill mode.  When this mode is on, Emacsbreaks the line in between words automatically whenever you inserttext 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 again by doing M-xauto 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 thecommand "toggles the mode".>> 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 make 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 text or backwardthrough it.  Searching for a string is a cursor motion command;it moves the cursor to the next place where that string appears.The Emacs search command is different from the search commandsof most editors, in that it is "incremental".  This means that thesearch happens while you type in the string to search for.The command to initiate a search is C-s for forward search, and C-rfor reverse search.  BUT WAIT!  Don't try them now.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -