[comp.editors] vi, word completion

dtau@mullian.ee.mu.oz.au (David Au) (07/09/90)

In article <745@utsun.s.u-tokyo.ac.jp> you write:
>In other words, the ^K macro would be mapped in its entirety as:
>
>    :map! ^K ^[a.^[bmmi?\<^[2h"zdt.@z^Mywmx`mPbea ^[dwbia^["zdt.x@z
>                            ==
I believe someone has already pointed out this macro has a problem when
there is text immediately to the right of the cursor. And that is a big
problem because quite often you would want to insert text in the middle of a
sentense. The following is a slight improvement on the previously posted
macro, but may be someone out there has a better solution:

map!  a. bbmmi?\<2h"zdt.@z
map!  a. bbdw`xnywmx`mPbea dwbis"zdt.x@z
map!  a. bbdw`xNywmx`mPbea dwbis"zdt.x@z

cheers,

David Au
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|  David Au                         |  ACSnet   : dtau@mullian.ee.mu.oz       |
|  Department of Elec Engineering   |  internet : dtau@mullian.ee.mu.oz.au    |
|  University of Melbourne          |  uunet    : uunet!munnari!mullian!dtau  |

lee@sq.sq.com (Liam R. E. Quin) (07/10/90)

dtau@mullian.ee.mu.OZ.AU (David Au) writes:
>The following is a slight improvement on the previously posted
>macro, but may be someone out there has a better solution:
>
>map!  a. bbmmi?\<2h"zdt.@z
>map!  a. bbdw`xnywmx`mPbea dwbis"zdt.x@z
>map!  a. bbdw`xNywmx`mPbea dwbis"zdt.x@z

This is not an improvement at all.  It is a syntax error.  :-(
The trick when posting these things is to use the two-character representation
with a caret (^) -- ^K, ^[, etc., rather than the actual control character.
If you don't do this, the network strips out most of the control characters,
and the vi macros don't work any more....

I'm not able to reconstruct this exactly, so I don't know if it's better,
but the "bb" near the beginning concerns me -- better to use 3h or 2h (which
depends on the missing control chars I think) -- in case there was
punctuation immediately to the left.

Lee
-- 
Liam R. E. Quin,  lee@sq.com, {utai,utzoo}!sq!lee,  SoftQuad Inc., Toronto
``Sun. n.s.,  Any thing eminently splendid'' [Johnson's dictionary (1837)]

dtau@mullian.ee.mu.oz.au (David Au) (07/11/90)

In article <1990Jul10.151510.17011@sq.sq.com> lee@sq.sq.com (Liam R. E. Quin) writes:
>dtau@mullian.ee.mu.OZ.AU (David Au) writes:
>>The following is a slight improvement on the previously posted
>>macro, but may be someone out there has a better solution:
>>
>>map!  a. bbmmi?\<2h"zdt.@z
>>map!  a. bbdw`xnywmx`mPbea dwbis"zdt.x@z
>>map!  a. bbdw`xNywmx`mPbea dwbis"zdt.x@z
>
>This is not an improvement at all.  It is a syntax error.  :-(
>The trick when posting these things is to use the two-character representation
>with a caret (^) -- ^K, ^[, etc., rather than the actual control character.
>If you don't do this, the network strips out most of the control characters,
>and the vi macros don't work any more....
>
>I'm not able to reconstruct this exactly, so I don't know if it's better,
>but the "bb" near the beginning concerns me -- better to use 3h or 2h (which
>depends on the missing control chars I think) -- in case there was
>punctuation immediately to the left.

I'm sorry about not paying attention to the control characters in the last
posting. Here is what it should have looked like:

    map! ^K ^[a. ^[bbmmi?\<^[2h"zdt.@z^Mywmx`mPbea ^[dwbis^["zdt.x@z
    map! ^N ^[a. ^[bbdw`xnywmx`mPbea ^[dwbis^["zdt.x@z
    map! ^P ^[a. ^[bbdw`xNywmx`mPbea ^[dwbis^["zdt.x@z

It is true that in the general case it is better to use hb instead of bb.
In this case, because both the punctuation and the following space are
intentionally appended, I thought it didn't matter as long as it works. So
change it to hb if it makes anybody happier.

An alternative to the above fix is as follows. The advantage of doing it
this way I guest depends on the vi implementation that you are using. On the
one that I'm using to write this posting, undo takes you back to ?\<xxx. On
another implementation, it removes the last append, and in which case the
following way do not leave you with an extra space after you undo. I
personally prefer the following method.

    map! ^K ^[a.^[bmmi?\<^[2h"zdt.hmn@z^Mywmx`mPbea ^[dwbia^["zdt.x`n@z
    map! ^N ^[a.^[bdw`xnywmx`mPbea ^[dwbia^["zdt.x`n@z
    map! ^P ^[a.^[bdw`xNywmx`mPbea ^[dwbia^["zdt.x`n@z

It's good to hear from someone.

Cheers,

David Au
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|  David Au                         |  ACSnet   : dtau@mullian.ee.mu.oz       |
|  Department of Elec Engineering   |  internet : dtau@mullian.ee.mu.oz.au    |
|  University of Melbourne          |  uunet    : uunet!munnari!mullian!dtau  |

bluetrol@sun.udel.edu (Bluetroll) (07/11/90)

In article <4789@munnari.oz.au> dtau@mullian.ee.mu.OZ.AU (David Au) writes:
>     map! ^K ^[a. ^[bbmmi?\<^[2h"zdt.@z^Mywmx`mPbea ^[dwbis^["zdt.x@z
>     map! ^N ^[a. ^[bbdw`xnywmx`mPbea ^[dwbis^["zdt.x@z
>     map! ^P ^[a. ^[bbdw`xNywmx`mPbea ^[dwbis^["zdt.x@z

I am using version SVR3.1 on a sun 3/50 under SunOS 4.1.  With this
version the ^K macro worked but the ^N and ^P would fail because
deleting the period at the end of the ^K macro also deleted the m
mark.  I had to add mm to both of them.
     map! ^N ^[a. ^[bbdwmm`xnywmx`mPbea ^[dwbis^["zdt.x@z
     map! ^P ^[a. ^[bbdwmm`xNywmx`mPbea ^[dwbis^["zdt.x@z
                        ^^
I like these macros!

					    Doke Scott