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

📄 543-545.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=543-545//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="541-543.html">Previous</A></TD>

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

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

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Starting <I>emacs</I> by Using an Existing File

</FONT></H4>

<P>To edit or look at a file that already exists in your current directory, enter <TT><I>emacs</I></TT> followed by the filename. For example, try this with the file you created in the previous section by entering this command:</P>

<!-- CODE SNIP //-->

<PRE>

<B>emacs emacs-pract.1</B>

</PRE>

<!-- END CODE SNIP //-->

<P>You see the following:

</P>

<!-- CODE SNIP //-->

<PRE>

Things to do today.

a. Practice emacs.

b. Sort sales data and print the results.

</PRE>

<!-- END CODE SNIP //-->

<P>Look at the mini-buffer: It contains the name of the file you&#146;re editing.

</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TROUBLESHOOTING:&nbsp;&nbsp;</B><BR><B>I typed a filename I know exists, but</B> <TT><I>emacs</I></TT> <B>acts as though I&#146;m creating a new file</B>. You may have typed the name of a file incorrectly, or you may have typed one that doesn&#146;t exist in your current directory. If, for example, you type <TT>emacs pract1.</TT> and press &lt;Return&gt; but there&#146;s no file named pract1. in your current directory, <TT>emacs</TT> still starts, but because the named file doesn&#146;t exist, <TT>emacs</TT> acts as though you were creating a new file.

<P><B>I try to edit a file, but</B> <TT>emacs</TT> <B>displays a message about read permission being denied, and the shell prompt appears.</B> You&#146;ve tried to edit a file you aren&#146;t permitted to read. Also, you can&#146;t edit a directory-that is, if you type <TT>emacs</TT> <TT><I>directory_name</I></TT>, where <TT>directory_name</TT> is the name of a directory, <TT>emacs</TT> informs you that you opened a directory and won&#146;t let you edit it. If you try to use <TT>emacs</TT> with a binary file instead of an ASCII file, you&#146;ll see a screen full of strange (control) characters&#151;something you cannot read and edit. <TT>emacs</TT> expects files to be stored as plain text.</P>

<P><B>When I tried to open a file in</B> <TT><I>emacs</I></TT>, <B>I got a message about the line being too long.</B> You&#146;re trying to use <TT>emacs</TT> on a data file or a binary file that&#146;s just one long string of bytes.</P>

<P><B>When I try to save a file with the &lt;Ctrl-x&gt;&lt;Ctrl-s&gt; keys, the terminal hangs and doesn&#146;t respond to the keyboard.</B> Your terminal is probably responding to the flow-control characters &lt;Ctrl-s&gt; and &lt;Ctrl-q&gt;. Press &lt;Ctrl-q&gt; to restart your session.</P>

<P><B>I opened a file in <TT><I>emacs</I></TT>, and some strange characters appeared on-screen.</B> You may be using <TT>emacs</TT> with a file produced by a word processor.</P>

<P>In all these cases, press &lt;Ctrl-x&gt;&lt;Ctrl-c&gt; to exit emacs and return to your login shell prompt. Then answer n to the prompt asking if you want to save the file. Using those keystrokes ensures that you quit <TT>emacs</TT> and make no changes to the existing file.<HR></FONT>

</BLOCKQUOTE>

</P>

<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Exiting <I>emacs</I>

</FONT></H4>

<P>As already stated, to exit <TT>emacs</TT>, press &lt;Ctrl-x&gt;&lt;Ctrl-c&gt;. If you haven&#146;t saved any changes to the file, <TT>emacs</TT> prompts you to save the buffer. If you type y, <TT>emacs</TT> saves the file and returns you to the Linux shell. If you haven&#146;t provided a filename, emacs prompts for a filename and then exits. If you respond <I>n</I> to the request to save the buffer, <TT>emacs</TT> prompts again to make sure that you want to exit without saving the buffer. This time you must completely type out the response to the prompt&#151;<TT><I>yes</I></TT> or <TT><I>no</I></TT>. If you answer yes, <TT>emacs</TT> returns you to Linux without saving any of the modifications you made to the buffer. Also, if you have multiple buffers open, <TT>emacs</TT> prompts you for each buffer.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>CAUTION:&nbsp;&nbsp;</B><BR>The default installation of <TT>emacs</TT> performs periodic saves while you&#146;re editing a buffer. <TT>emacs</TT> does not, per se, make backup copies of files, although the first time you save the file, a snapshot of the file is saved in <TT>#filename#</TT>. After you press &lt;Ctrl-x&gt;&lt;Ctrl-s&gt;, the original file is modified and can&#146;t be restored to its original state. Thus, you should make your own backup copies of <TT>emacs</TT> files before starting the editing session to make sure that the automatic updates don&#146;t inadvertently overwrite an important file to the point where you can&#146;t recover a previous version of the file.<HR></FONT>

</BLOCKQUOTE>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>CAUTION:&nbsp;&nbsp;</B><BR>Answer <I>n</I> to the exit-without-saving prompt sparingly. When you answer <I>n</I>, all the changes you&#146;ve made to the file since it was last saved are lost. It&#146;s better to be safe and save the file to a different filename if you&#146;re not sure about losing all your changes to the file.<HR></FONT>

</BLOCKQUOTE>

<P>Perhaps you aren&#146;t quite finished with your <TT>emacs</TT> session but you need to perform other activities with Linux. In that case, you have several options:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;You can suspend <TT>emacs</TT> and return to the Linux shell.

<DD><B>&#149;</B>&nbsp;&nbsp;You can switch to another virtual terminal.

<DD><B>&#149;</B>&nbsp;&nbsp;You can issue a shell command from within <TT>emacs</TT>.

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="541-543.html">Previous</A></TD>

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

<TD><A HREF="545-546.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 + -