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

📄 548-549.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=548-549//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

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

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

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

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Positioning the Cursor</FONT></H4>

<P>When you edit text, you need to position the cursor where you want to insert additional text, delete text, correct mistakes, change words, or append text to the end of existing text. The commands you enter are called <I>cursor-positioning commands</I>.</P>

<P><FONT SIZE="+1"><B>The Arrow Keys</B></FONT></P>

<P>You can use the arrow keys on many&#151;but not all&#151;systems to position the cursor. It&#146;s easy to see whether the arrow keys work: Start <TT>emacs</TT> with an existing file and see what effects the arrow keys have. You may also be able to use the &lt;Page Up&gt; and &lt;Page Down&gt; keys.</P>

<P>Enter the following command to create a new file called emacs-pract.3 that contains a list of the files and directories in the directory /usr. You can use this file to experiment with cursor-positioning commands.</P>

<!-- CODE SNIP //-->

<PRE>

<B>ls /usr &gt; emacs-pract.3</B>

</PRE>

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

<P>If you create the file with the &lt;Ctrl-u&gt;&lt;Esc&gt;&lt;!&gt; command sequence, you see the following message:

</P>

<!-- CODE SNIP //-->

<PRE>

(Shell command completed with no output)

</PRE>

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

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B>Don&#146;t worry about the message; it doesn&#146;t mean there&#146;s a problem. Standard output was redirected to the file and, thus, <TT>emacs</TT> had no output to capture to a buffer.<HR></FONT>

</BLOCKQUOTE>

<P>When the file is created, start <TT>emacs</TT> with the emacs-pract.3 file (type <TT><B>emacs emacs-pract.3</B></TT> and press &lt;Return&gt;). Now try using the arrow keys and the &lt;Page Up&gt; and &lt;Page Down&gt; keys (if they&#146;re on your keyboard) to move around the editing buffer. If the keys work, you may want to use those keys for cursor positioning.</P>

<P>It may be that, although it appears that the cursor-positioning keys work, they&#146;re introducing strange characters into the file. These characters are the codes the computer uses to represent the various keys instead of the characters themselves. If you see such characters, you have to use the various keyboard commands to position the cursor instead of using the keyboard keys.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>To clear the screen of spurious or unusual characters in <TT>emacs</TT>, press &lt;Ctrl-l&gt;.<HR></FONT>

</BLOCKQUOTE>

<P><FONT SIZE="+1"><B>Other Cursor-Movement Keys</B></FONT></P>

<P>You can position the cursor in <TT>emacs</TT> in other ways without using the arrow keys. You should become familiar with these methods in case you can&#146;t or don&#146;t want to use the arrow keys. This section also shows you some ways to position the cursor more efficiently than using the arrow keys.</P>

<P>When <TT>emacs</TT> was developed in 1975, many terminals didn&#146;t have arrow keys; other keys were and still are used to position the cursor. It takes a little practice to get comfortable with these keys, but some experienced <TT>emacs</TT> users prefer these keys over the arrow keys. Here are some other keys that move the cursor:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-f&gt; to move the cursor to the right (&#147;forward&#148;) one position.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-b&gt; to move the cursor to the left (&#147;back&#148;) one position.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-n&gt; to move to the beginning of the next line, preserving your position in the line.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-p&gt; to move to the previous line, preserving your position in the line.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-a&gt; to move to the beginning of a line.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Ctrl-e&gt; to move to the end of a line.

</DL>

<P>Some <TT>emacs</TT> commands allow you to position the cursor relative to words on a line. A <TT>word</TT> is defined as a sequence of characters separated from other characters by spaces or usual punctuation symbols, such as periods, question marks, commas, and hyphens. These commands are as follows:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Esc&gt;&lt;f&gt; to move forward one word.

<DD><B>&#149;</B>&nbsp;&nbsp;Press &lt;Esc&gt;&lt;b&gt; to move backward one word.

</DL>

<P>The following example demonstrates some of these actions. Start <TT>emacs</TT> and open the emacs-pract.1 file by typing <TT><B>emacs emacs-pract.1</B></TT> and pressing &lt;Return&gt;. Now use any of the cursor-positioning commands just described to move the cursor, indicated by an underline character, to the <I>t</I> in the word &#147;data&#148; on the third line of the file. The third line looks like this:</P>

<!-- CODE SNIP //-->

<PRE>

b. Sort sales da<U>t</U>a and print the results.

</PRE>

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

<P>To move to the beginning of the next word, press &lt;Esc&gt;&lt;f&gt;; the cursor is positioned under the <TT><I>a</I></TT> of the word &#147;and&#148; in the previous sentence. Press &lt;Esc&gt;&lt;f&gt; to move to the <TT><I>p</I></TT> in &#147;print.&#148; To move to the beginning of the word &#147;and,&#148; press &lt;Esc&gt;&lt;b&gt;; the cursor is positioned under the <TT>a</TT> in &#147;and&#148; again.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

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

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

<TD><A HREF="549-551.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 + -