VI - Bug or feature?????

Burch Seymour bseymour at potpourri.UUCP
Tue Jul 19 04:52:37 AEST 1988


I noticed the following strange behavior of vi and, while it's not exactly
a critical problem, I am curious as to whether vi is flawed, or my 
understanding of the way vi does searches is flawed.

Consider the following three lines of text:

loog loog loog loog loog loog
loog loog loog loog loog loog
loog loog loog loog loog loog

Now search for loog using '/loog<cr>' followed by 'n' as required. Vi will
stop the cursor on each word in the three lines. Fine so far. Now search
using '/l.*g<cr>' and 'n'. Vi will stop at the first position of each line.
This, or so I am told, is because vi matches the longest possible pattern,
and the whole line matches, so the next match is on the next line. Fair
enough. Now the buggy part.  Position the cursor on some character other
than the first one on any of those lines. Then do the '/l.*g<cr>'. I would
expect it to stop at the next occurance of 'l' on that line. It does not.
It will stop at the first position of the next line. Anyone care to 
speculate why? And is that a correct thing for it to do?

-Burch Seymour-  ...uunet!gould!bseymour   or whatever else you can conjure up
----------------------------------------



More information about the Comp.unix.questions mailing list