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

📄 ch32_11.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 32] 32.11 Using Word Abbreviation Mode </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:46:39Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch32_01.htm"TITLE="32. GNU Emacs"><LINKREL="prev"HREF="ch32_10.htm"TITLE="32.10 Inserting Binary Characters into Files "><LINKREL="next"HREF="ch32_12.htm"TITLE="32.12 Getting Around Emacs Flow Control Problems "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_10.htm"TITLE="32.10 Inserting Binary Characters into Files "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 32.10 Inserting Binary Characters into Files "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 32<BR>GNU Emacs</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_12.htm"TITLE="32.12 Getting Around Emacs Flow Control Problems "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 32.12 Getting Around Emacs Flow Control Problems "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7860">32.11 Using Word Abbreviation Mode </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-7860-IX-ABBREVIATIONS-EMACS-EDITOR"></A><ACLASS="indexterm"NAME="UPT-ART-7860-IX-KEYBOARD-SHORTCUTS-ABBREVIATIONS-IN-EMACS"></A><ACLASS="indexterm"NAME="UPT-ART-7860-IX-EMACS-EDITOR-ABBREVIATIONS"></A>Like <EMCLASS="emphasis">vi</EM>, Emacs provides an &quot;abbreviation&quot; facility.  Itstraditional usage lets you define abbreviations for long words orphrases so you don't have to type them in their entirety.  Forexample, let's say you are writing a contract which repeatedlyreferences the National Institute of Standards and Technology.  Ratherthan typing the full name, you can define the abbreviation<CODECLASS="literal">nist</CODE>.  Emacs inserts the full name whenever you type<CODECLASS="literal">nist</CODE>, followed by a space or punctuation mark.  Emacs watchesfor you to type an abbreviation, then expands it automatically as soonas you press the space bar or type a punctuation mark (such as<CODECLASS="literal">. , ! ? ; :</CODE>).</P><PCLASS="para">One use for word abbreviation mode is to correct misspellings as youtype.  Almost everyone has a dozen or so words that they habituallytype incorrectly, due to some worn neural pathways.  You can simplytell Emacs that these misspellings are &quot;abbreviations&quot; for the correctversions, and Emacs fixes the misspellings every time you typethem. If you take time to define your common typos as abbreviations,you'll never have to be bothered with <CODECLASS="literal">teh</CODE>, <CODECLASS="literal">adn</CODE>, and<CODECLASS="literal">recieve</CODE> when you run the spellchecker. Emacs sweeps up behindyour typos and corrects them. For example, let's say that you define<CODECLASS="literal">teh</CODE> as an abbreviation for <CODECLASS="literal">the</CODE>.  When you press thespace bar after you type <CODECLASS="literal">teh</CODE>, Emacs fixes it immediately whileyou continue happily typing. You may not even notice that you typedthe word wrong before Emacs fixes it.</P><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7860-SECT-1.1">32.11.1 Trying Word Abbreviations for One Session </A></H3><PCLASS="para">Usually, if you go to the trouble of defining a word abbreviation, youwill use it in more than one Emacs session. But if you'd like to tryout abbreviation mode to see if you want to make it part of yourstartup, you can use the following procedure.</P><PCLASS="para">To define word abbreviations for this session:</P><OLCLASS="orderedlist"><LICLASS="listitem"><PCLASS="para">Enter word abbreviation mode by typing <CODECLASS="literal">ESC&nbsp;x&nbsp;abbrev-mode</CODE>.<CODECLASS="literal">abbrev</CODE> appears on the mode line.</P></LI><LICLASS="listitem"><PCLASS="para">Type the abbreviation you want to use and press <CODECLASS="literal">CTRL-x a</CODE>. Emacs then asks you for the expansion.</P></LI><LICLASS="listitem"><PCLASS="para">Type the definition for the abbreviation and press RETURN.Emacs then expands the abbreviation and will do so each time you type itfollowed by a space or punctuation mark.The abbreviations you'vedefined will work only during this Emacs session.</P></LI></OL><PCLASS="para">If you find that you like using word abbreviation mode, you may wantto make it part of your startup, as described in the followingsection.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-7860-SECT-1.2">32.11.2 Making Word Abbreviations Part of Your Startup </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-36146"></A>Once you become hooked on abbreviation mode, make it part of your<EMCLASS="emphasis">.emacs</EM> file so that you enter abbreviation mode and load thefile of your word abbreviations and their definitionsautomatically. To define word abbreviations and make them part of yourstartup:</P><OLCLASS="orderedlist"><LICLASS="listitem"><PCLASS="para">Add these lines to your <EMCLASS="emphasis">.emacs</EM> file:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">(setq-default abbrev-mode t)(read-abbrev-file &quot;~/.abbrev_defs&quot;)(setq save-abbrevs t)</PRE></BLOCKQUOTE></P><PCLASS="para"></P></LI><LICLASS="listitem"><PCLASS="para">Save the <EMCLASS="emphasis">.emacs</EM> file and reenter Emacs.<CODECLASS="literal">Abbrev</CODE> appears on the mode line. (You'll get an error at thispoint; ignore it&nbsp;- it won't happen again.)</P></LI><LICLASS="listitem"><PCLASS="para">Type an abbreviation you want to use and then type <CODECLASS="literal">CTRL-x a</CODE>following the abbreviation. Emacs asks you for the expansion.</P></LI><LICLASS="listitem"><PCLASS="para">Type the definition for the abbreviation and press RETURN.Emacs expands the abbreviation and will do so each time you type itfollowed by a space or punctuation mark. You can define as manyabbreviations as you want to by repeating steps 3 and 4.</P></LI><LICLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">ESC&nbsp;x&nbsp;write-abbrev-file</CODE> to save your abbreviationsfile.Emacs asks for the filename. </P></LI><LICLASS="listitem"><PCLASS="para">Type <CODECLASS="literal">~/.abbrev_defs</CODE>.Emacs then writes the file. You need only take this step the first timeyou define abbreviations using this procedure. After this file exists,the lines in your <EMCLASS="emphasis">.emacs</EM> file load the abbreviations fileautomatically.</P></LI></OL><PCLASS="para">After you've followed this procedure the first time, you only need touse steps 3 and 4 to define more abbreviations. When you addword abbreviations in subsequent sessions, Emacs asks whether you want to save the abbreviations file. Respond with a<CODECLASS="literal">y</CODE> to savethe new abbreviations you've defined and have them take effectautomatically.</P><PCLASS="para">If you define an abbreviation and later regret it, use<EMCLASS="emphasis">edit-word-abbrevs</EM> to delete it.<ACLASS="indexterm"NAME="AUTOID-36176"></A><ACLASS="indexterm"NAME="AUTOID-36177"></A><ACLASS="indexterm"NAME="AUTOID-36178"></A></P></DIV><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">DC</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_10.htm"TITLE="32.10 Inserting Binary Characters into Files "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 32.10 Inserting Binary Characters into Files "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch32_12.htm"TITLE="32.12 Getting Around Emacs Flow Control Problems "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 32.12 Getting Around Emacs Flow Control Problems "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">32.10 Inserting Binary Characters into Files </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">32.12 Getting Around Emacs Flow Control Problems </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

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