📄 ch30_31.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 30] 30.31 vi Word Abbreviation </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:45:51Z"><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="ch30_01.htm"TITLE="30. vi Tips and Tricks"><LINKREL="prev"HREF="ch30_30.htm"TITLE="30.30 vi Outsmarts Dual-Function Function Keys "><LINKREL="next"HREF="ch30_32.htm"TITLE="30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)"></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="ch30_30.htm"TITLE="30.30 vi Outsmarts Dual-Function Function Keys "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 30.30 vi Outsmarts Dual-Function Function Keys "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 30<BR>vi Tips and Tricks</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch30_32.htm"TITLE="30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)"BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-5270">30.31 vi Word Abbreviation </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-5270-IX-VI-EDITOR-ABBREVIATIONS"></A><ACLASS="indexterm"NAME="UPT-ART-5270-IX-KEYBOARD-SHORTCUTS-VI-ABBREVIATIONS"></A><ACLASS="indexterm"NAME="UPT-ART-5270-IX-EX-EDITOR-ABBREVIATIONS"></A><ACLASS="indexterm"NAME="UPT-ART-5270-IX-ABBREVIATIONS-VI-AND-EX-EDITORS"></A>You can define abbreviations that <EMCLASS="emphasis">vi</EM> will automatically expand into the full text whenever you type the abbreviation during text-input mode.To define an abbreviation, use the <EMCLASS="emphasis">ex</EM> command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:ab</B></CODE> <CODECLASS="replaceable"><I>abbr phrase</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para"><EMCLASS="emphasis">abbr</EM> is an abbreviation for the specified<EMCLASS="emphasis">phrase</EM>.The sequence of characters that make up the abbreviation will beexpanded during text-input mode only if you type it as a full word;<EMCLASS="emphasis">abbr</EM> will not be expanded within a word.[I abbreviate <EMCLASS="emphasis">Covnex</EM> to <EMCLASS="emphasis">Convex</EM>, my company's name,because I have dyslexic fingers. <EMCLASS="emphasis">-TC</EM> ]</P><PCLASS="para">Suppose you want to enter text thatcontains a phrase that occurs frequently, such as a difficult productor company name. The command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:ab ns the Nutshell Handbook</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">abbreviates <EMCLASS="emphasis">the Nutshell Handbook</EM> to the initials <EMCLASS="emphasis">ns</EM>.Now whenever you type <EMCLASS="emphasis">ns</EM> as a separate word duringtext-input mode, <EMCLASS="emphasis">ns</EM> expands to the full text.</P><PCLASS="para">Abbreviations expand as soon as you press a non-alphanumeric character(e.g., punctuation), a carriage return, or ESC(returning to command mode).[1]When you are choosing abbreviations, choose combinations ofcharacters that don't ordinarily occur while you are typing text.If you create an abbreviation that ends up expanding in placeswhere you don't want it to, you can disable the abbreviation bytyping:</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[1] An abbreviation won't expand when you type an underscore ( <CODECLASS="literal">_</CODE> );it's treated as part of the abbreviation.</P></BLOCKQUOTE><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:unab</B></CODE> <CODECLASS="replaceable"><I>abbr</I></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">To list your currently defined abbreviations, type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:ab</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">The characters that compose your abbreviation cannot also appear at the end of your phrase.For example, if you issue the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:ab PG This movie is rated PG</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">you'll get the message <CODECLASS="literal">No tail recursion</CODE>,and the abbreviation won't be set. The message means that you have tried to define something that willexpand itself repeatedly, creating an infinite loop.If you issue the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen"><CODECLASS="userinput"><B>:ab PG the PG rating system</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">you may or may not produce an infinite loop, but in either caseyou won't get a warning message.For example, when the above command was tested on a System V versionof UNIX, the expansion worked. On a Berkeley version though,the abbreviation expanded repeatedly, like this:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">the the the the the ...</PRE></BLOCKQUOTE></P><PCLASS="para">until a memory error occurred and <EMCLASS="emphasis">vi</EM> quit.We recommend that you avoid repeating your abbreviationas part of the defined phrase.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">DD</SPAN>, <SPANCLASS="authorinitials">DG</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="ch30_30.htm"TITLE="30.30 vi Outsmarts Dual-Function Function Keys "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 30.30 vi Outsmarts Dual-Function Function Keys "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="ch30_32.htm"TITLE="30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">30.30 vi Outsmarts Dual-Function Function Keys </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">30.32 Using vi Abbreviations as Commands (Cut and Paste Between vi's)</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 & 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 + -