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

📄 ch31_03.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 31] 31.3 What You Lose When You Use map! </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:12Z"><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="ch31_01.htm"TITLE="31. Creating Custom Commands in vi"><LINKREL="prev"HREF="ch31_02.htm"TITLE="31.2 Save Time and Typing with the vi map Commands "><LINKREL="next"HREF="ch31_04.htm"TITLE="31.4 vi @-Functions "></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="ch31_02.htm"TITLE="31.2 Save Time and Typing with the vi map Commands "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.2 Save Time and Typing with the vi map Commands "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 31<BR>Creating Custom Commands in vi</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch31_04.htm"TITLE="31.4 vi @-Functions "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.4 vi @-Functions "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7610">31.3 What You Lose When You Use map! </A></H2><PCLASS="para">Back in the old days (when bread cost five cents and my grandfather wasjust a boy...) a terminal's arrow keys didn't work during <EMCLASS="emphasis">vi</EM>text-input mode.To move around in the file, you pressed ESC and used command-modecommands like <EMCLASS="emphasis">5k</EM> and <EMCLASS="emphasis">4w</EM>.Since then, lots of vendors and users have modified <EMCLASS="emphasis">vi</EM> so thatyou can use arrow keys during text-input mode.In fact, we show you how to do it yourself in articles<ACLASS="xref"HREF="ch31_02.htm"TITLE="Save Time and Typing with the vi map Commands ">31.2</A>and<ACLASS="xref"HREF="ch31_13.htm"TITLE="Making Cursor Keys Work in vi Text-input Mode ">31.13</A>.These days, lots of folks think the newfangled way that <EMCLASS="emphasis">vi</EM> worksis the right way.Here are some reasons to leave the arrow keys aloneand do it the old way instead:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">In most cases, the <CODECLASS="literal">u</CODE> (undo) command will be useless after text-inputmode because the arrow keymap does several hidden commands.The only &quot;undo&quot; command that will do much good is <CODECLASS="literal">U</CODE>-it undoes allchanges on the current line, and it doesn't work if you've moved off theline since you made the change you want to undo.</P></LI><LICLASS="listitem"><PCLASS="para">Beginners can get confused by this.They need to learn that <EMCLASS="emphasis">vi</EM> is a moded editor, that you enter textin text-input mode and make changes in command mode.Movement through the file is with commands.</P><PCLASS="para">When people start using <EMCLASS="emphasis">vi</EM> and they find that some motion commands(the cursor keys) work in text-input mode, <EMCLASS="emphasis">vi</EM> seems inconsistent.</P></LI><LICLASS="listitem"><PCLASS="para">If your <CODECLASS="literal">map!</CODE> runs commands that start with an ESC (and it almostalways will), your ESC key may work more slowly.That's because every time you press the ESC key, <EMCLASS="emphasis">vi</EM> will wait onesecond (or so) to be sure that the ESC is just an ESC alone and not thebeginning of a <CODECLASS="literal">map!</CODE>ped sequence.Some vendors have changed this, though.</P><PCLASS="para">The fast alternative is to press ESC twice.That rings the terminal bell, though.</P></LI></UL><ACLASS="indexterm"NAME="AUTOID-35028"></A><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</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="ch31_02.htm"TITLE="31.2 Save Time and Typing with the vi map Commands "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.2 Save Time and Typing with the vi map Commands "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="ch31_04.htm"TITLE="31.4 vi @-Functions "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.4 vi @-Functions "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">31.2 Save Time and Typing with the vi map Commands </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">31.4 vi @-Functions </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 + -