[comp.editors] line moving while in insert mode

mostek@motcid.UUCP (Frank B. Mostek) (04/18/91)

In vi:

Can the cursor be moved up/down lines while in insert mode?  If I make
a mistake and don't realize it before I hit CR, I always hit <ESC> to
move up/down.  Is there an easier way?  I can always map a key, but I
was wondering if there was a natural vi feature.

My apologies if this is a faq, I don't read this very often.

Also, '0' doesn't work for me all the time. (get to start of line.) Its
not working for me now (while I'm in nn).  What could be causing this?
It also does not work when I edit files in my home directory.  It works
any other time I use vi.  Any ideas?

I am on:

SunOS Release 4.0.3 (SDW403.STD3X.V1.1) #1: Sun Nov 12 19:52:18 CST 1989

My .exrc:

map 0 mz
map - "wy`z
map = "wP
map @V1@ 1G!Gvspell
:map V @V2@
map @V2@ 1Gd/---- spell check complete ---/+0
:map V @V1@
map V @V1@
map v {!}fmt -80
set ai
set bf
set sm
-- 
************************************************************
Frank Mostek			uunet!motcid!amethyst!mostek
Software Consultant 		(708)632-7191
************************************************************

rouben@math9.math.umbc.edu (Rouben Rostamian) (04/22/91)

[I tried to send this message via mail but it bounced.  Sorry.]

In article <6219@beryl12.UUCP> you write:
>In vi:
>
>Can the cursor be moved up/down lines while in insert mode?
Yes, you can use :map! to define keys in the insert mode.  I would
not reommend it though, since it goes against the spirit of vi, and 
any short-term advantages are offset by the long-term handicaps
it causes.

>Also, '0' doesn't work for me all the time. (get to start of line.) Its
>not working for me now (while I'm in nn).  What could be causing this?
>It also does not work when I edit files in my home directory.  It works
>any other time I use vi.  Any ideas?

You won't need to look beyond the first line of your .exrc:
>map 0 mz
It redefines 0 to mz.  Do you mean to do that?  In fact, are the keymap
definitions in your .exrc intentional?  They certainly are strange, and
sub-optimal in my opinion.  I do no see what is gained by overriding the
default definitions of some of vi's most frequently used keys.
I would delete the .exrc file if I were you.

The reason that the strange definitions in your .exrc do not handicap you
in directories other than the home directory, is that your environment
most probably includes a EXINIT variable.  Whenever EXINIT is defined,
vi skips .exrc, except when .exrc is in the current directory.

Hope that this helps.  Should you need further explanation, send me
an email.

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu

rosen@cbnewsb.cb.att.com (steven.b.rosen) (04/22/91)

In article <6219@beryl12.UUCP>, mostek@motcid.UUCP (Frank B. Mostek) writes:
> In vi:
> 
> Can the cursor be moved up/down lines while in insert mode?  If I make
> a mistake and don't realize it before I hit CR, I always hit <ESC> to
> move up/down.  Is there an easier way?  I can always map a key, but I
> was wondering if there was a natural vi feature.
> 

	The only movement I know of while in insert mode is ^W (control W).
	This will back you up one word. You can type this as many times as
	you want, but you cant back up beyond your initial insert point. If
	you find any commands, please post them here.

		...steve...

	PS: Does anyone have any constructive comments about the "elvis" 
		gnu vi clone? I'd like to have vi on my pc, and free is a good
		price. But I dont want to waste my time downloading & compiling 
		if it's not worth it.

----------------------------------------
Steve Rosen               attmail!srosen
                      srosen@attmail.com
----------------------------------------

shore@theory.tn.cornell.edu (Melinda Shore) (04/22/91)

In article <1991Apr22.031302.5020@cbfsb.att.com> rosen@cbnewsb.cb.att.com (steven.b.rosen) writes:
>	The only movement I know of while in insert mode is ^W (control W).
>	This will back you up one word.

It will *delete* the previous word you typed on that line during
the current insert/append spree.  That's not the same as backing
up one word.
-- 
                    Software longa, hardware brevis
Melinda Shore - Cornell Information Technologies - shore@theory.tn.cornell.edu

hansm@cs.kun.nl (Hans Mulder) (04/24/91)

In <1991Apr22.031302.5020@cbfsb.att.com> rosen@cbnewsb.cb.att.com (steven.b.rosen) writes:

>	The only movement I know of while in insert mode is ^W (control W).
>	This will back you up one word. You can type this as many times as
>	you want, but you cant back up beyond your initial insert point. If
>	you find any commands, please post them here.

Control-W *deletes* the last word you typed.  The word remains on the screen
as a hint in case you wanted to type something similar.  It will disappear
if you type over it or if escape out of insertion mode.
And you can't always back up to your insertion point, because you can't ^W
back to the previous line.

There are several other control keys for deleting something in insertion mode:
backspace (^H) erases the last character (but not beyond the insertion point
nor beyond the left margin).  If your erase character outside vi is not ^H
than whatever it is works as well.

Your line kill character (^U or whatever you set it to) erases the entire
input line (except the whitespace generated by autoindent mode), or back to
the insertion point if that is on the current line.

^D on the beginning of an autoindented line decreases the autoindent by one
shiftwidth.  ^T increases it by 1 shiftwidth.  0^D erases all the whitespace
generated by autoindent.  ^^D (that is: a caret followed by a control-D)
erases all the autoindented whitespace, but reinstates it on the next line.

The other character that inserts something non-obvious is ^@.  When typed
as the very first character in insertion mode, it inserts the same text
you inserted last time (provided it is less than 128 characters) and ends
insertion mode.

--
Have a nice day,

Hans Mulder	hansm@cs.kun.nl

mostek@motcid.UUCP (Frank B. Mostek) (04/24/91)

rouben@math9.math.umbc.edu (Rouben Rostamian) writes:

>In article <6219@beryl12.UUCP> you write:

>You won't need to look beyond the first line of your .exrc:
>>map 0 mz

These mappings help me with cut and paste.  The control chars did not
get displayed.  The actual map is:
                                                         
map CTRL-VPause mz	#map Pause key in Sun keyboard
map CTRL-VPrSc  "wy`z
map CTRL-VSLB   "wP
                                                      
Also, there were some newlines in there...

>The reason that the strange definitions in your .exrc do not handicap you
>in directories other than the home directory, is that your environment
>most probably includes a EXINIT variable.  Whenever EXINIT is defined,
>vi skips .exrc, except when .exrc is in the current directory.

I find these mappings very helpful, and they do work in other
directories, i.e., EXINIT is not defined in my environment.  However,
the 0 does work when I move the .exrc file, so I changed the key to one
that does not contain a 0 in its control sequence, and that fixed the
problem.  It's still a mystery why the problem only occurred in the
home directory, i.e., why did the mappings work, but the 0 did not get
erroneously mapped?
-- 
Frank Mostek			uunet!motcid!amethyst!mostek
(708)632-7191			mostek@amethyst.mot.com

jerry@talos.npri.com (Jerry Gitomer) (04/25/91)

rosen@cbnewsb.cb.att.com (steven.b.rosen) writes (in response to another
article):

|	The only movement I know of while in insert mode is ^W (control W).
|	This will back you up one word. You can type this as many times as
|	you want, but you cant back up beyond your initial insert point. If
|	you find any commands, please post them here.


The following map commands allow me to use my cursor keys to move around
while in insert mode.  (If you right arrow to the last character in a line
you will get bounced out of insert mode, but otherwise they work as
expected.)

map! OA ka
map! OB ja
map! OC lli
map! OD i

|	PS: Does anyone have any constructive comments about the "elvis"
|		gnu vi clone? I'd like to have vi on my pc, and free is a good
|		price. But I dont want to waste my time downloading & compiling
|		if it's not worth it.

I am using elvis and like it.  I use vi throughout the day and find that
elvis is close enough to vi to fool me.  A bonus, IMHO, is that since I
have the source I can add (or strip out) features as the spirit moves me.

			Jerry

-- 
Jerry Gitomer at National Political Resources Inc, Alexandria, VA USA
I am apolitical, have no resources, and speak only for myself.
Ma Bell (703)683-9090  (UUCP:  ...uunet!uupsi!npri6!jerry )

jerry@talos.npri.com (Jerry Gitomer) (04/27/91)

jerry@talos.npri.com (Jerry Gitomer) writes:

|rosen@cbnewsb.cb.att.com (steven.b.rosen) writes (in response to another
|article):

||	The only movement I know of while in insert mode is ^W (control W).
||	This will back you up one word. You can type this as many times as
||	you want, but you cant back up beyond your initial insert point. If
||	you find any commands, please post them here.


|The following map commands allow me to use my cursor keys to move around
|while in insert mode.  (If you right arrow to the last character in a line
|you will get bounced out of insert mode, but otherwise they work as
|expected.)

|map! OA ka
|map! OB ja
|map! OC lli
|map! OD i

	Oops!  I should have realized that either vi or the mailer would
	nail me on the escape characters I copied from in my .exrc.  What I
	meant to have you see is:

		map! ^[0A ^[ka
		map! ^[0B ^[ja
		map! ^[0C ^[lli
		map! ^[0D ^[i

	The easy way of entering the map commands is to do as follows:

	map!  SPACE   CTL-V UP-ARROW   SPACE     CTL-V ESC ka
	map!  SPACE   CTL-V DOWN-ARROW   SPACE     CTL-V ESC ja
	map!  SPACE   CTL-V RIGHT-ARROW   SPACE     CTL-V ESC lli 
	map!  SPACE   CTL-V LEFT-ARROW   SPACE     CTL-V ESC i

||	PS: Does anyone have any constructive comments about the "elvis"
||		gnu vi clone? I'd like to have vi on my pc, and free is a good
||		price. But I dont want to waste my time downloading & compiling
||		if it's not worth it.

|I am using elvis and like it.  I use vi throughout the day and find that
|elvis is close enough to vi to fool me.  A bonus, IMHO, is that since I
|have the source I can add (or strip out) features as the spirit moves me.

-- 
Jerry Gitomer at National Political Resources Inc, Alexandria, VA USA
I am apolitical, have no resources, and speak only for myself.
Ma Bell (703)683-9090  (UUCP:  ...uunet!uupsi!npri6!jerry )