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

📄 tutorial

📁 早期freebsd实现
💻
📖 第 1 页 / 共 3 页
字号:
You've now learned the most basic way of typing something inEmacs and correcting errors.  You can delete by words or linesas well.  Here is a summary of the delete operations:	<Rubout>     delete the character just before the cursor	C-d   	     delete the next character after the cursor	M-<Rubout>   kill the word immediately before the cursor	M-d	     kill the next word after the cursor	C-k	     kill from the cursor position to end of line	M-k	     kill to the end of the current sentenceNotice that <Rubout> and C-d vs M-<Rubout> and M-d extend the parallelstarted by C-f and M-f (well, <Rubout> isn't really a controlcharacter, but let's not worry about that).  C-k and M-k are like C-eand M-e, sort of, in that lines are opposite sentences.Now suppose you kill something, and then you decide that you want toget it back?  Well, whenever you kill something bigger than acharacter, Emacs saves it for you.  To yank it back, use C-y.  Youcan kill text in one place, move elsewhere, and then do C-y; this isa good way to move text around.  Note that the differencebetween "Killing" and "Deleting" something is that "Killed" thingscan be yanked back, and "Deleted" things cannot.  Generally, thecommands that can destroy a lot of text save it, while the ones thatattack only one character, or nothing but blank lines and spaces, donot save.For instance, type C-n a couple times to postion the cursorat some line on this screen.>> Do this now, move the cursor and kill that line with C-k.Note that a single C-k kills the contents of the line, and a secondC-k kills the line itself, and make all the other lines move up.  Ifyou give C-k a repeat count, it kills that many lines AND theircontents.The text that has just disappeared is saved so that you canretrieve it.  To retrieve the last killed text and put it wherethe cursor currently is, type C-y.>> Try it; type C-y to yank the text back.Think of C-y as if you were yanking something back that someonetook away from you.  Notice that if you do several C-k's in a rowthe text that is killed is all saved together so that one C-y willyank all of the lines.>> Do this now, type C-k several times.Now to retrieve that killed text:>> Type C-y.  Then move the cursor down a few lines and type C-y   again.  You now see how to copy some text.What do you do if you have some text you want to yank back, and thenyou kill something else?  C-y would yank the more recent kill.  Butthe previous text is not lost.  You can get back to it using the M-ycommand.  After you have done C-y to get the most recent kill, typingM-Y replaces that yanked text with the previous kill.  Typing M-yagain and again brings in earlier and earlier kills.  When youhave reached the text you are looking for, you can just go away andleave it there.  If you M-y enough times, you come back to thestarting point (the most recent kill).>> Kill a line, move around, kill another line.   Then do C-y to get back the second killed line.   Then do M-y and it will be replaced by the first killed line.   Do more M-y's and see what you get.  Keep doing them until   the second kill line comes back, and then a few more.   If you like, you can try giving M-y positive and negative   arguments.UNDO----Any time you make a change to the text and wish you had not done so,you can undo the change (return the text to its previous state)with the undo command, C-x u.  Normally, C-x u undoes one command'sworth of changes; if you repeat the C-x u several times in a row,each time undoes one more command.  There are two exceptions:commands that made no change (just moved the cursor) do not count,and self-inserting characters are often lumped together in groupsof up to 20.  This is to reduce the number of C-x u's you have to type.>> Kill this line with C-k, then type C-x u and it should reappear.C-_ is another command for undoing; it is just the same as C-x ubut easier to type several times in a row.  The problem with C-_ isthat on some keyboards it is not obvious how to type it.  That iswhy C-x u is provided as well.  On some DEC terminals, you can typeC-_ by typing / while holding down CTRL.  Illogical, but what canyou expect from DEC?Giving a numeric argument to C-_ or C-x u is equivalent to repeatingit as many times as the argument says.FILES-----In order to make the text you edit permanent, you must put it in afile.  Otherwise, it will go away when your invocation of Emacs goesaway.  You put your editing in a file by "finding" the file.  Whatfinding means is that you see the contents of the file in your Emacs;and, loosely speaking, what you are editing is the file itself.However, the changes still don't become permanent until you "save" thefile.  This is so you can have control to avoid leaving a half-changedfile around when you don't want to.  Even then, Emacs leaves theoriginal file under a changed name in case your changes turn outto be a mistake.If you look near the bottom of the screen you will see a line thatbegins and ends with dashes, and contains the string "Emacs: TUTORIAL".Your copy of the Emacs tutorial is called "TUTORIAL".  Whateverfile you find, that file's name will appear in that precisespot.The commands for finding and saving files are unlike the othercommands you have learned in that they consist of two characters.They both start with the character Control-x.  There is a whole seriesof commands that start with Control-x; many of them have to do withfiles, buffers, and related things, and all of them consist ofControl-x followed by some other character.Another thing about the command for finding a file is that you haveto say what file name you want.  We say the command "reads an argumentfrom the terminal" (in this case, the argument is the name of thefile).  After you type the command	C-x C-f   Find a fileEmacs asks you to type the file name.  It echoes on the bottomline of the screen.  You are using the minibuffer now!  this iswhat the minibuffer is for.  When you type <Return> to end thefile name, the minibuffer is no longer needed, so it disappears.>> Type C-x C-f, then type C-g.  This cancels the minibuffer,   and also cancels the C-x C-f command that was using the   minibuffer.  So you do not find any file.In a little while the file contents appear on the screen.  You canedit the contents.  When you wish to make the changes permanent,issue the command	C-x C-s   Save the fileThe contents of Emacs are written into the file.  The first time youdo this, the original file is renamed to a new name so that itis not lost.  The new name is made by appending "~" to the endof the original file's name.When saving is finished, Emacs prints the name of the file written.You should save fairly often, so that you will not lose very muchwork 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.   On VMS it will print "Wrote ...[...]TUTORIAL."To make a new file, just find it "as if" it already existed.  Thenstart typing in the text.  When you ask to "save" the file, Emacswill really create the file with the text that you have inserted.From then on, you can consider yourself to be editing an alreadyexisting file.BUFFERS-------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.The object inside Emacs which holds the text read from one fileis called a "buffer."  Finding a file makes a new buffer inside Emacs.To see a list of the buffers that exist in Emacs, 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 namefor the file whose contents it holds.  Some buffers do not correspondto files.  For example, the buffer named "*Buffer List*" doesnot have any file.  It is the buffer which contains the bufferlist that was made by C-x C-b.  ANY text you see in an Emacs windowhas to be in some buffer.>> Type C-x 1 to get rid of the buffer list.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 goes through the list of all the buffers you haveand finds the ones that contain files you have changed.For each such buffer, C-x s asks you whether to save it.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 twoof them: the file commands C-x C-f to Find and C-x C-s to Save.Another example is the command to tell Emacs that you'd like to stopediting and get rid of Emacs.  The command to do this is C-x C-c.(Don't worry; it offers to save each changed file before it kills theEmacs.)C-z is the usual way to exit Emacs, because it is always better not tokill the Emacs if you are going to do any more editing.  On systemswhich allow it, C-z exits from Emacs to the shell but does not destroythe Emacs; if you use the C shell, you can resume Emacs with the `fg'command (or, more generally, with `%emacs', which works even if yourmost recent job was some other).  On systems where suspending is notpossible, C-z creates a subshell running under Emacs to give you thechance to run other programs and return to Emacs afterward, but itdoes not truly "exit" from Emacs.  In this case, the shell command`exit' is the usual way to get back to Emacs from the subshell.You would use C-x C-c if you were about to log out.  You wouldalso use it to exit an Emacs invoked under mail handling programsand other random utilities, since they may not believe you havereally finished using the Emacs if it continues to exist.There are many C-x commands.  The ones you know are:	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 u		Undo.Named eXtended commands are commands which are used even lessfrequently, or commands which are used only in certain modes.  Thesecommands are usually called "functions".  An example is the functionreplace-string, which globally replaces one string with another.  Whenyou type M-x, Emacs prompts you at the bottom of the screen withM-x and you should type the name of the function you wish to call; inthis case, "replace-string".  Just type "repl s<TAB>" and Emacs willcomplete the name.  End the command name with <Return>.Then type the two "arguments"--the string to be replaced, and the stringto replace it with--each one ended with a 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 occured   after the cursor.

⌨️ 快捷键说明

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