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

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

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

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

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

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

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Using <I>emacs</I>

</FONT></H3>

<P>You edit text by creating new text or by modifying existing text. When creating new text, you place the text in a file with an ordinary Linux filename. When you modify existing text, you use the existing filename to call a copy of the file into the editing session. In either case, as you use the editor, the text is held in the system&#146;s memory in a storage area called a buffer.

</P>

<P>Using a buffer prevents you from directly changing the contents of a file until you decide to save the buffer. This is to your benefit if you decide you want to forget the changes you&#146;ve made and start over.</P>

<P><TT>emacs</TT> allows you to edit multiple buffers at once. This way, you can cut and paste text from one buffer to another, compare text from different files, or merge one file into another file. <TT>emacs</TT> even uses a special buffer to accept commands and report information to the user. This buffer, the <I>mini-buffer</I>, appears at the bottom of the screen.</P>

<P><TT>emacs</TT> also lets you display the contents of various buffers in their own windows; thus, you can see several files at once, even if you aren&#146;t using a graphical user interface.</P>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Looking Over the <I>emacs</I> Screen

</FONT></H4>

<P>Figure 28.1 shows a typical <TT>emacs</TT> screen. The top portion displays the contents of various buffers, sometimes in multiple windows. Then a mode line is displayed at the bottom of the screen. This line, usually displayed in reverse video, provides users with information about the buffer, such as the buffer&#146;s name, the major and minor mode, and the amount of text displayed in the buffer. Under the mode line is the one-line mini-buffer, where you enter <TT>emacs</TT> commands and where <TT>emacs</TT> reports the outcome of various commands.</P>

<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/28-01.jpg',699,338 )"><IMG SRC="images/28-01t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/28-01.jpg',699,338)"><FONT COLOR="#000077"><B>FIG. 28.1</B></FONT></A>&nbsp;&nbsp;A typical <TT>emacs</TT> screen shows the buffer and mini-buffer areas.

</P>

<P>The current position in the buffer is shown by a cursor. <TT>emacs</TT> refers to the cursor as the <I>point</I>, especially in the online help system, so it&#146;s important to remember this term for the cursor.</P>

<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Creating Your First <I>emacs</I> File

</FONT></H4>

<P>The following instructions show how to edit your first <TT>emacs</TT> file. If you run into difficulties, you can quit and start over by pressing &lt;Ctrl-x&gt;&lt;Ctrl-c&gt;. Follow these steps:</P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Start <TT>emacs</TT> (type <TT><B>emacs</B></TT> and press &lt;Return&gt;). You see the screen shown in Figure 28.1.

<DD><B>2.</B>&nbsp;&nbsp;Add the following lines of text to the buffer:

<!-- CODE SNIP //-->

<PRE>

<I>Things to do today.</I>

<I>a. Practice emacs.</I>

<I>b. Sort sales data and print the results.</I>

</PRE>

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

<BR>You can use the &lt;Backspace&gt; key to correct mistakes on the line you&#146;re typing. Don&#146;t worry about being precise here: This example is for practice. You learn other ways to make changes in some of the later sections of this chapter.

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>Notice the mini-buffer at the bottom of the screen. Your keystrokes appear there because you&#146;re typing commands to the <TT>emacs</TT> editor.<HR></FONT>

</BLOCKQUOTE>

<DD><B>3.</B>&nbsp;&nbsp;Save your buffer in a file called emacs-pract.1. First press &lt;Ctrl-x&gt;&lt;Ctrl-s&gt; and type <TT><B>emacs-pract.1</B></TT>. Notice that <TT>emacs-pract.1</TT> appears at the bottom of the screen. Press &lt;Return&gt;. This command saves or writes the buffer to the file emacs-pract.1 (the specified file).

<BR>You should see the following confirmation on the status line:

<!-- CODE SNIP //-->

<PRE>

Wrote /root/emacs-pract.1

</PRE>

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

<BR>This statement confirms that the file emacs-pract.1 has been created and saved to disk. Your display may be different if you didn&#146;t type the information exactly as specified.

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>Notice the number of characters in the filename. Unlike MS-DOS and Windows, Linux allows you to enter more than eight characters and a three-character extension for a filename.<HR></FONT>

</BLOCKQUOTE>

<DD><B>4.</B>&nbsp;&nbsp;Exit <TT>emacs</TT> by pressing &lt;Ctrl-x&gt;&lt;Ctrl-c&gt; and then &lt;Return&gt;. If you have unsaved material, <TT>emacs</TT> might prompt you to save an unsaved buffer/file. If <TT>emacs</TT> does prompt you, simply press &lt;y&gt; to save the information, or &lt;n&gt; if you don&#146;t want to save the information. <TT>emacs</TT> then terminates, and you return to the login shell prompt.

</DL>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TROUBLESHOOTING:&nbsp;&nbsp;</B><BR><TT>emacs</TT> <B>is placing the characters I type into the mini-buffer and attempting to perform strange actions with the characters.</B> If you press the &lt;Esc&gt; key twice, <TT>emacs</TT> enters a LISP programming environment. LISP is the original language that Stallman used to program <TT>emacs</TT>, and it&#146;s through LISP that programmers can extend and customize <TT>emacs</TT>. If you press &lt;Esc&gt;&lt;Esc&gt;, <TT>emacs</TT> enters the eval-expression mode and expects the user to enter a LISP command; simply press &lt;Return&gt; to exit this mode.<HR></FONT>

</BLOCKQUOTE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

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

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

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