📄 ch31_13.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 31] 31.13 Making Cursor Keys Work in vi Text-input Mode </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:46:25Z"><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_12.htm"TITLE="31.12 Text-Input Mode Cursor Motion with No Arrow Keys "><LINKREL="next"HREF="ch31_14.htm"TITLE="31.14 Don't Lose Important Functions with vi Maps: Use noremap"></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_12.htm"TITLE="31.12 Text-Input Mode Cursor Motion with No Arrow Keys "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.12 Text-Input Mode Cursor Motion with No Arrow Keys "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_14.htm"TITLE="31.14 Don't Lose Important Functions with vi Maps: Use noremap"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.14 Don't Lose Important Functions with vi Maps: Use noremap"BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-6620">31.13 Making Cursor Keys Work in vi Text-input Mode </A></H2><PCLASS="para">Here is my <EMCLASS="emphasis">.exrc</EM> file, which I customized fora VT100 terminal.It is set up for C and <EMCLASS="emphasis">nroff -me</EM> macros.[Strings like <CODECLASS="literal">^[OD</CODE> are<SPANCLASS="link">set by the cursor keys (<ACLASS="linkend"HREF="ch41_12.htm"TITLE="Finding Out What Characters Your Terminal's Special Keys Send">41.12</A>)</SPAN>on VT100-type terminals.Make the <CODECLASS="literal">^[</CODE> by typing <KBDCLASS="keycap">[CTRL-v]</KBD> <KBDCLASS="keycap">[ESC]</KBD>.Many <EMCLASS="emphasis">vi</EM> versions make this easier; they understand<SPANCLASS="link"><CODECLASS="literal">map #1</CODE> (<ACLASS="linkend"HREF="ch31_02.htm"TITLE="Save Time and Typing with the vi map Commands ">31.2</A>)</SPAN>to mean "map function key F1."<EMCLASS="emphasis">-JP</EM> ]</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist"> <ACLASS="co"HREF="ch43_13.htm"TITLE="43.13 The Text Formatters nroff, troff, ditroff, ... ">troff</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen"> set ai redraw sm wm=1set tabstop=4set shiftwidth=4map! {} {^M}^[O^I <ICLASS="lineannotation">Great for auto indenting { } pairs</I>map! ^[OD ^[ha <ICLASS="lineannotation">Cursor left while inputting</I>map! ^[OA ^[ka <ICLASS="lineannotation">Cursor up while inputting</I>map! ^[OB ^[ja <ICLASS="lineannotation">Cursor down while inputting</I>map! ^[OC ^[la <ICLASS="lineannotation">Cursor right while inputting</I>map ^[OP A <ICLASS="lineannotation">Mapped F1 to append to end of line</I>map! ^[OP ^[A <ICLASS="lineannotation">Text-input mode of the above</I>map ^[OQ 0i <ICLASS="lineannotation">Mapped F2 to insert before line</I>map! ^[OQ ^[0i <ICLASS="lineannotation">Text-input mode of the above</I>map! `` \*(lq <ICLASS="lineannotation">troff left quote</I>map! '' \*(rq <ICLASS="lineannotation">troff right quote</I></PRE></TD></TR></TABLE></P><PCLASS="para">I can use the cursor keys while inputting text. This is handybecause I can back up and add text without pressing ESC.[Though you<SPANCLASS="link">may not be able to (<ACLASS="linkend"HREF="ch31_03.htm"TITLE="What You Lose When You Use map! ">31.3</A>)</SPAN>undo your previous change with the <EMCLASS="emphasis">u</EM> command.<EMCLASS="emphasis">-JP</EM> ]</P><PCLASS="para">Also, I have defined <KBDCLASS="keycap">[F1]</KBD>to append at the end of the line.This is useful because it doesn't matter what mode you are in,it always puts you in text-input mode.</P><PCLASS="para">At one time, I mapped the entire numeric keypad to emulate the EDT editor.<ACLASS="indexterm"NAME="AUTOID-35688"></A></P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">BB</SPAN> <SPANCLASS="bibliomisc">in <ACLASS="systemitem.newsgroup"HREF="news:net.unix">net.unix</A> on Usenet, 9 October 1986</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_12.htm"TITLE="31.12 Text-Input Mode Cursor Motion with No Arrow Keys "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.12 Text-Input Mode Cursor Motion with No Arrow 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="ch31_14.htm"TITLE="31.14 Don't Lose Important Functions with vi Maps: Use noremap"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.14 Don't Lose Important Functions with vi Maps: Use noremap"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">31.12 Text-Input Mode Cursor Motion with No Arrow 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">31.14 Don't Lose Important Functions with vi Maps: Use noremap</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 + -