Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!att!cbnews!smk From: smk@cbnews.att.com (Stephen M. Kennedy) Newsgroups: comp.editors Subject: Re: Another bug in vi ? Summary: vi feature Message-ID: <1990Oct3.150431.19010@cbnews.att.com> Date: 3 Oct 90 15:04:31 GMT References: <896@pcsbst.pcs.com> Organization: AT&T Bell Laboratories Lines: 35 In article <896@pcsbst.pcs.com>, wd@samsa.pcs.com (wd) writes: > If I define > > :map! #a foo > > and type "#a" while in insert mode, my version of vi appends some > garbage after inserting "foo" (usually it looks like "fooa", but > I have seen "fooli" and other garbage, too). This happens only if > the first character of the mapped pattern is a '#'. It does not > depend on the rest of the pattern. Believe it or not, this is a vi (mis?)feature. A lhs of '#a' means function key 'a' to vi. Yes, even though you probably don't have a function key 'a'; a more common usage is '#1' for function key 1, etc. In insert/replace/append mode, vi seems to expect function keys to map to a rhs that does an to go into command mode and then does cursor positioning commands. Vi then endeavors to put you back into insert/replace/append mode at the right spot with the appropriate 'a', 'i', 'li', etc. commands. Your "function key" definition doesn't follow this undocumented protocol, so you get the trailing 'a' or 'li' garbage because you never left insert mode in the first place. Vi predefines mappings for the up, down, left, right, and home function keys for most terminals. I'm not sure I see the utility of this kind of cursor positioning within i/r/a mode; perhaps for editing a table in replace mode? Workarounds? - Don't use # as the first character of the lhs. - End rhs with (gak) (I didn't try this either) Steve Kennedy smk@cbosgd.att.com > Company : PCS GmbH, Pfaelzer-Wald-Str. 36, 8000 Munich W-Germany. Congratulations! I hope it works out for you.