[comp.editors] history behind <count>command<count>movement behavior in vi

rac@sherpa.UUCP (Roger Cornelius) (11/13/90)

Something I've wondered about vi is the purpose behind its behavior when
a command of the following form is given:

For commands followed by a movement, e.g.  `cw', `d}', etc., if both
the command and the movement are preceded by a count, then the command
affects count*count objects.  If the command `5d5d' is given, then 25
lines are deleted.  `3y6y' yanks 18 lines and `2c3w' changes 6 words.

I've never seen this mentioned in any documentation I've read - Is it
just a side affect of parsing the command and movements separately, or
maybe it's there to get around some internal limit in vi?

--
Roger A. Cornelius          rac@sherpa.UUCP         uunet!sherpa!rac

fyl@ssc.UUCP (Phil Hughes) (11/15/90)

In article <391@sherpa.UUCP>, rac@sherpa.UUCP (Roger Cornelius) writes:
> Something I've wondered about vi is the purpose behind its behavior when
> a command of the following form is given:

> For commands followed by a movement, e.g.  `cw', `d}', etc., if both
> the command and the movement are preceded by a count, then the command
> affects count*count objects.  If the command `5d5d' is given, then 25
> lines are deleted.  `3y6y' yanks 18 lines and `2c3w' changes 6 words.

> I've never seen this mentioned in any documentation I've read - Is it
> just a side affect of parsing the command and movements separately, or
> maybe it's there to get around some internal limit in vi?

I even teach this in my class.  I guess you could look at it as a side
effect but it makes sense.  Look at dw for example.
     10dw      10 deletes of a word
     d10w      a delete of 10 words
     2d5w      two deletes of five words

It seems that it "just happened" and was allowed because it makes sense.
Much the same as there is no "command" to exchange the current letter with
the one following it but it can be done with two commands: x and p
     x        delete current letter
     p        put most recent delete back after current letter
So,
     xp       echanges the current letter with the one following it

There always seems to be another way to do things in vi.  A few years ago
a student asked my why you couldn't use some obscure command (I forget
which) one to do a simple task.  I told him I had never heard of it.  He
said, "it's right here in on the VI Reference Card you gave me."  Guess
that's why we publish them. :-)
-- 
Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155  (206)FOR-UNIX
     uunet!pilchuck!ssc!fyl or attmail!ssc!fyl            (206)527-3385