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

📄 546-548.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Using the emacs Editor</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=28//-->

<!--PAGES=546-548//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="545-546.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="548-549.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Undoing a Command</FONT></H4>

<P>In <TT>emacs</TT>, you can &#147;undo&#148; your most recent action or change to the buffer, as long as you have not saved that change to the disk file. You can undo by pressing &lt;Ctrl-x&gt;&lt;u&gt;. By repeatedly using this command, you can undo the changes made to the buffer.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><TT>emacs</TT> keeps track of the &#147;undone&#148; material first in memory buffers and then in a file, so theoretically you could undo every change you&#146;ve made to a buffer up to the limits of your disk space. Practically, though, you&#146;ll find the undo command useful for only the last few commands or edits you&#146;ve done.<HR></FONT>

</BLOCKQUOTE>

<P>Unfortunately, you can&#146;t use the undo command to undo writing something to a file as opposed to writing to the buffer.

</P>

<P>If you want to reread a file from disk (thus overwriting your current buffer changes), you can press &lt;Ctrl-x&gt;&lt;Ctrl-r&gt;. This command reads the specified file into the current buffer, erasing its previous contents. Thus, if you specify the same filename, <TT>emacs</TT> replaces the current buffer with the contents of the file on disk. This is a quick way to undo many changes without exiting and restarting <TT>emacs</TT>.</P>

<P>But what if the <TT>emacs</TT> has autosaved the file or you&#146;ve saved the file with unwanted changes? Well, <TT>emacs</TT> creates a backup file the first time you save a file, but not until you save the file. The name of this backup file is the same as the filename, except with a # character at the beginning and end of the name. Thus, if your file was named emacs-prtc.1, the backup filename is #emacs-prtc.1#. If you accidentally overwrite your current file with unwanted changes, you may be able to use the backup file to start over.</P>

<H3><A NAME="Heading9"></A><FONT COLOR="#000077">Writing Files and Saving the Buffer</FONT></H3>

<P>You&#146;ve seen how to write the buffer to a file and quit <TT>emacs</TT>. Sometimes, however, you want to save the buffer to a file without quitting <TT>emacs</TT>. You should save the file regularly during an editing session. If the system goes down because of a crash or a power failure, you may lose your work if you haven&#146;t saved it recently. To save the buffer, press &lt;Ctrl-x&gt;&lt;Ctrl-s&gt;.</P>

<P>If you started <TT>emacs</TT> without specifying a filename, you must provide a filename if you want to save the file to disk. In this case, you press &lt;Ctrl-x&gt;&lt;Ctrl-s&gt;, type the filename, and press &lt;Return&gt;.</P>

<P>You may want to save the buffer to a new filename different from the one you originally started with. For example, you start <TT>emacs</TT> with the file emacs-pract.1, make some changes to the file, and want to save the changes to a new file without losing the original emacs-pract.1 file. To save the file with a new filename, press &lt;Ctrl-x&gt;&lt;Ctrl-w&gt;. <TT>emacs</TT> prompts you for the filename. The buffer is then written to the named file. If the command is successful, you see the name of the file.</P>

<P>If you specify the name of an existing file, a message appears in the mini-buffer, asking whether you want to overwrite the file. Simply answer the question appropriately.</P>

<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Using Files</FONT></H4>

<P>If you want to load another file to edit, <TT>emacs</TT> can let you load a new file into the current buffer, or load a file into a new buffer, leaving the current buffer alone. <TT>emacs</TT> also lets you insert the contents of a file into the current buffer.</P>

<P>To replace the current buffer with the contents of another file, press &lt;Ctrl-x&gt;&lt;Ctrl-v&gt;. <TT>emacs</TT> prompts for a filename in the mini-buffer. If you don&#146;t remember the entire filename or if the name is rather long, you can use the completion option of <TT>emacs</TT>. When <TT>emacs</TT> prompts for a filename, you can enter just the first few letters in the name and then press &lt;Tab&gt;. <TT>emacs</TT> then expands the filename to match any files with those first few letters. If more than one file matches, <TT>emacs</TT> displays a window containing all the files matching the characters you entered and allows you to choose one.</P>

<P>To retrieve a file into a new buffer, press &lt;Ctrl-x&gt;&lt;Ctrl-f&gt;. Enter the filename at the mini-buffer prompt. <TT>emacs</TT> normally names the buffer after the filename, but you can change the name of the buffer by pressing &lt;Esc&gt;&lt;x&gt;, entering the new name for the buffer, and pressing &lt;Return&gt;. <TT>emacs</TT> prompts for the new name. Enter the new buffer name and press &lt;Return&gt;. The mode line displays the new name.</P>

<P>To insert a file into the current buffer, simply move the cursor to the desired position in the file and press &lt;Ctrl-x&gt;&lt;i&gt;.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="545-546.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="548-549.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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