stevea@locus.com (Steve Anderson) (02/08/91)
Is there any way to backspace past the beginning of the line when you're in insert or append mode? For example, I hit i, type "Is there any...". I get to "in", and now I want to backspace to "line" while still in insert mode. Possible? -- -Steve A. Anderson I do not speak officially for Locus or IBM, just me. stevea@locus.com ...{uunet|ucla-se|sequent}!lcc!stevea vi: Vogon Inspired
jerry@TALOS.UUCP (Jerry Gitomer) (02/08/91)
stevea@locus.com (Steve Anderson) writes:
:Is there any way to backspace past the beginning of the line when
:you're in insert or append mode?
:For example, I hit i, type "Is there any...". I get to "in", and now
:I want to backspace to "line" while still in insert mode. Possible?
Yes, using the :map facility of vi. I picked this trick up
from Tom Christenson's articles here. Just do the following
(I used the four arrow keys since most of us have modern
keyboards):
:map! ^[0A ^[ka
:map! ^[0B ^[ja
:map! ^[0C ^[lli
:map! ^[0D ^[i
to enter the first line type
:map ! CTL-V <up-arrow-key> CTL-V <escape-key> ka
The other lines are entered in a similar manner :-)
--
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: ...{uupsi,vrdxhq}!pbs!npri6!jerry
dattier@ddsw1.MCS.COM (David W. Tamkin) (02/12/91)
jerry@TALOS.UUCP (Jerry Gitomer) wrote in <1012@TALOS.UUCP>: | Yes, using the :map facility of vi. I picked this trick up | from Tom Christenson's articles here. Just do the following | (I used the four arrow keys since most of us have modern | keyboards): | | :map! ^[0A ^[ka | :map! ^[0B ^[ja | :map! ^[0C ^[lli | :map! ^[0D ^[i ^[lli? That won't work aif you started out at the end of the line. True, cursoring right from the end of a line makes no sense, but if you bump into the right arrow key you'll be in trouble. Try :map! ^[0C ^[la instead. Tom Christiansen should have known that ... unless Tom Christenson is some other person. David Tamkin Box 7002 Des Plaines IL 60018-7002 708 518 6769 312 693 0591 MCI Mail: 426-1818 GEnie: D.W.TAMKIN CIS: 73720,1570 dattier@ddsw1.mcs.com
em@dce.ie (Eamonn McManus) (02/12/91)
dattier@ddsw1.MCS.COM (David W. Tamkin) writes: >| :map! ^[0A ^[ka >| :map! ^[0B ^[ja >| :map! ^[0C ^[lli >| :map! ^[0D ^[i > >^[lli? That won't work aif you started out at the end of the line. True, >cursoring right from the end of a line makes no sense, but if you bump into >the right arrow key you'll be in trouble. As I've pointed out before, another problem with macros like these is that it is impossible to get the up and down arrows to work properly at the start of a line. When you leave insert mode, vi backs up one character except if it is already at the start of the line. Hence macros cannot tell if you were on the first or second character. The macros above will move right one character as well as up or down, when invoked at the start of the line. , Eamonn
jerry@TALOS.UUCP (Jerry Gitomer) (02/12/91)
dattier@ddsw1.MCS.COM (David W. Tamkin) writes: |jerry@TALOS.UUCP (Jerry Gitomer) wrote in <1012@TALOS.UUCP>: || Yes, using the :map facility of vi. I picked this trick up || from Tom Christenson's articles here. Just do the following || (I used the four arrow keys since most of us have modern || keyboards): || || :map! ^[0A ^[ka || :map! ^[0B ^[ja || :map! ^[0C ^[lli || :map! ^[0D ^[i |^[lli? That won't work aif you started out at the end of the line. True, |cursoring right from the end of a line makes no sense, but if you bump into |the right arrow key you'll be in trouble. |Try :map! ^[0C ^[la instead. Tom Christiansen should have known that ... |unless Tom Christenson is some other person. Mea culpa, mea culpa, mea culpa. I apologize for not spelling Tom Christiansen's name incorrectly. As far as the action of the right arrow key is concerned, neither alternative is ideal, but vi gives us the liberty to pick that which is least evil :-) to the definer. -- 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: ...{uupsi,vrdxhq}!pbs!npri6!jerry
stevea@locus.com (Steve Anderson) (02/13/91)
Thanks, Jerry, et. al., but what I meant to ask for was to have the backspace actually work past the beginning of the line. In hopes of being clear as an unmuddied lake, here's a gratuitous illustration. 1--press i and type 1.3 lines of text This is a bunch of text that I've been typing just as an example and it seems to go on and on =cursor here> ^ 2--backspace to "example"... This is a bunch of text that I've been typing just as an example =cursor here> ^ 3--type what I should have typed This is a bunch of text that I've been typing just as an example. Having the sentence end there is much better. La la la =cursor here> ^ -- -Steve A. Anderson I do not speak officially for Locus or IBM, just me. stevea@locus.com ...{uunet|ucla-se|sequent}!lcc!stevea vi: Vogon Inspired
wyle@inf.ethz.ch (Mitchell Wyle) (02/13/91)
In <21933@.la.locus.com> stevea@locus.com (Steve Anderson) laments: >backspace actually work past the beginning of the line. In hopes of >being clear as an unmuddied lake, here's a gratuitous illustration. > >1--press i and type 1.3 lines of text >This is a bunch of text that I've been typing just as an example and it >seems to go on and on >=cursor here> ^ > >2--backspace to "example"... > >This is a bunch of text that I've been typing just as an example >=cursor here> ^ > >3--type what I should have typed > >This is a bunch of text that I've been typing just as an example. Having >the sentence end there is much better. La la la >=cursor here> ^ 1. Vi in wrap mode auto-wraps for you, in partial violation of the line- orientation. 2. You can't backspace past begining-of-line. You can: <ESC>ddbbD that is, leave insert mode <ESC> delete the current line dd go back some words bb Delete to end of line D I admit the line-orientation metaphor is sometimes weak, but other times it is better to put your mind into "edit" mode and use 5 keystrokes, instead of absent-mindedly pushing the delete button a few dozen times. Elvis will backspace past beginning of line. Sometimes I think it's neat; other times I get angry at it for not being vi. To you use vi effectively, you have to use the modes.