📄 ch31_12.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 31] 31.12 Text-Input Mode Cursor Motion with No Arrow Keys </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_11.htm"TITLE="31.11 Typing in Uppercase Without CAPS LOCK "><LINKREL="next"HREF="ch31_13.htm"TITLE="31.13 Making Cursor Keys Work in vi Text-input Mode "></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_11.htm"TITLE="31.11 Typing in Uppercase Without CAPS LOCK "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.11 Typing in Uppercase Without CAPS LOCK "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_13.htm"TITLE="31.13 Making Cursor Keys Work in vi Text-input Mode "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.13 Making Cursor Keys Work in vi Text-input Mode "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0160">31.12 Text-Input Mode Cursor Motion with No Arrow Keys </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-160-IX-VI-EDITOR-CURSOR-MOTION-IN-INPUT-MODE"></A>Some people don't like to press ESC first to move the cursorwhile they're using <EMCLASS="emphasis">vi</EM>. These keymaps change CTRL-h,CTRL-j, CTRL-k, and CTRL-l to do the same thingsduring input mode as the commands <CODECLASS="literal">h</CODE>, <CODECLASS="literal">j</CODE>, <CODECLASS="literal">k</CODE>, and<CODECLASS="literal">l</CODE> do in command mode.</P><BLOCKQUOTECLASS="note"><PCLASS="para"><STRONG>NOTE:</STRONG> Is your<SPANCLASS="link">erase character set to CTRL-h (<ACLASS="linkend"HREF="ch05_09.htm"TITLE="Setting Your Erase, Kill, and Interrupt Characters ">5.9</A>)</SPAN>outside <EMCLASS="emphasis">vi</EM>? If it is, mapping CTRL-h (usually labeledBACKSPACE on your keyboard) will change the way CTRL-hworks during text-input mode: Instead of erasing the characters you'vetyped since you entered text-input mode, now CTRL-h will movebackwards over what you type without erasing it.One workaround is to change your UNIX erase character to the DELETEor RUBOUT key by typing the command <CODECLASS="literal">stty erase '?'</CODE> beforeyou start <EMCLASS="emphasis">vi</EM>.Then your DELETE key will erase what you type and the BACKSPACE key willjump back over it without deleting.</P></BLOCKQUOTE><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="exrc">exrc</A><BR></TH><TDVALIGN="TOP">The lines for your<SPANCLASS="link"><EMCLASS="emphasis">.exrc</EM> file (<ACLASS="linkend"HREF="ch04_09.htm"TITLE="Setting Up vi with the .exrc File ">4.9</A>)</SPAN>are below:</TD></TR></TABLE><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">map! H [imap! K [kamap! L [lamap! V [ja" Note: the two lines above map J (LINEFEED)</PRE></BLOCKQUOTE></P><PCLASS="para">That last map takes two lines; it's tricky and may not work right onall versions of <EMCLASS="emphasis">vi</EM>.No, it isn't a map for CTRL-v, though that's what it looks like.It maps <CODECLASS="literal">J</CODE>, the LINEFEED key.The <CODECLASS="literal">V</CODE> comes at the very end of its line.When you're entering that keymap, type CTRL-v and thenpress LINEFEED or CTRL-j.The cursor will move to the start of the next line; type a SPACEand the rest of the macro.It's a good idea to add the reminder comment (starting with the commentcharacter, a double quote (<CODECLASS="literal">"</CODE>)), on the line below the map.</P><BLOCKQUOTECLASS="note"><PCLASS="para"><STRONG>NOTE:</STRONG> This map for CTRL-j is pretty obviously something that thepeople who wrote my version of <EMCLASS="emphasis">vi</EM> didn't plan for.For example, look at the mess it makes when I ask for a list of my text-inputkeymaps:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">:<CODECLASS="userinput"><B>map!</B></CODE>H H [iK K [kaL L [la [ja</PRE></BLOCKQUOTE></P><PCLASS="para">Before you use this map on important files, you should probably test itcarefully.</P></BLOCKQUOTE><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_11.htm"TITLE="31.11 Typing in Uppercase Without CAPS LOCK "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 31.11 Typing in Uppercase Without CAPS LOCK "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_13.htm"TITLE="31.13 Making Cursor Keys Work in vi Text-input Mode "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 31.13 Making Cursor Keys Work in vi Text-input Mode "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">31.11 Typing in Uppercase Without CAPS LOCK </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.13 Making Cursor Keys Work in vi Text-input Mode </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 + -