📄 553-554.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=553-554//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="551-553.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="555-557.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>When <TT>emacs</TT> finds an occurrence of <TT>Linux</TT>, it stops and prompts for an action. The possible responses are as follows:</P>
<TABLE WIDTH="100%"><TR>
<TH WIDTH="30%" ALIGN="LEFT">Keystroke
<TH WIDTH="70%" ALIGN="LEFT">Action
<TR>
<TD><Ctrl-g>
<TD>Cancels operation
<TR>
<TD><!>
<TD>Replaces the rest without prompting
<TR>
<TD><?>
<TD>Gets a list of options
<TR>
<TD><.>
<TD>Replaces the current instance and quits
<TR>
<TD VALIGN="TOP"><,>
<TD>Replaces current instance but doesn’t move on to next instance
<TR>
<TD><y> or Spacebar
<TD>Replaces and continues with replace operation
<TR>
<TD><n>
<TD>Doesn’t replace but continues with replace operation
</TABLE>
<P><FONT SIZE="+1"><B>Changing Text</B></FONT></P>
<P>Another editing task you’re often faced with is changing text or replacing one text string with another (there isn’t too much difference between the two operations). You use the replace commands to replace a single character or sequence of characters. You can also use the change commands to fix one of the most common typing mistakes made—transposing two letters. Table 28.3 summarizes the change commands.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 28.3</B> Change Commands
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="27%" ALIGN="LEFT">Keystroke
<TH WIDTH="73%" ALIGN="LEFT">Action
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD><Ctrl-t>
<TD>Transposes two adjacent letters
<TR>
<TD><Esc><t>
<TD>Transposes two words
<TR>
<TD><Ctrl-x><Ctrl-t>
<TD>Transposes two lines
<TR>
<TD><Esc><c>
<TD>Properly capitalizes the word (initial capitalization)
<TR>
<TD><Esc><l>
<TD>Lowercases the entire word
<TR>
<TD><Esc><u>
<TD>Uppercases the entire word
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>The changes take place relative to the position of the cursor. Position the cursor at the location in the buffer file you want to correct before using these commands.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">Copying, Cutting, and Pasting</FONT></H4>
<P>When you delete or cut characters, words, lines, or a portion of a line, the deleted object is saved in what’s called the <I>kill buffer</I>. The name isn’t too important; what’s important is that you can put or paste the contents of the kill buffer anywhere in the text you’re editing. You do that with <Ctrl-y>, the yank command. <Ctrl-y> pastes the object to the right of or after the cursor position.</P>
<P>Here is an example showing the use of <Ctrl-y> to paste the contents of the kill buffer after the cursor:</P>
<P><I>Before:</I></P>
<!-- CODE SNIP //-->
<PRE>
Carefully carry these <U>o</U>ut instructions.
</PRE>
<!-- END CODE SNIP //-->
<P>Delete the word “out” and a space by pressing <Esc-d>. Now move the cursor to the space after the <I>y</I> in “carry” and press <Ctrl-y>.</P>
<P><I>After:</I></P>
<!-- CODE SNIP //-->
<PRE>
Carefully carry out these instructions.
</PRE>
<!-- END CODE SNIP //-->
<P>To copy a sequence of four lines to another portion of the text, you must first mark the four lines of text, delete them to the kill buffer, and then yank them back at the appropriate places. Follow these steps:
</P>
<DL>
<DD><B>1.</B> Position the cursor at the beginning of the first of the four lines.
<DD><B>2.</B> Press <Ctrl-Spacebar> to set the mark.
<DD><B>3.</B> Move the cursor to the end of the fourth line. This creates what <TT>emacs</TT> refers to as a <I>region</I>.
<DD><B>4.</B> Delete the text by pressing <Ctrl-w>.
<DD><B>5.</B> Because you want to copy the lines, you must replace the deleted text. Do this with the <Ctrl-y> command.
<DD><B>6.</B> Move the cursor to the point in the buffer where you want to copy the text.
<DD><B>7.</B> Press <Ctrl-y> to paste the yanked lines below the line holding the cursor.
</DL>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TROUBLESHOOTING: </B><BR><B>I deleted the marked region, but the region I marked wasn’t deleted.</B> Unfortunately, GNU <TT>emacs</TT> supplied with Linux doesn’t display any type of marker to indicate the mark, so it’s very easy to forget to set the mark or to place it in an inappropriate position. To check the position of the mark, use the command <Ctrl-x><Ctrl-x>. This command swaps the position of the cursor and the mark. If the cursor moves to the position where you thought the mark was located, you know the mark is properly set. To move the cursor back to the proper position, simply reissue <Ctrl-x><Ctrl-x> to swap them back.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="551-553.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="555-557.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 + -