James G. Sack (jim) wrote:

Ralph Shumaker wrote:
James G. Sack (jim) wrote:
Ralph Shumaker wrote:
..
In vim, I get the same one-line result with the vim command
:/\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\)
*That* gets me what I was expecting (though I don't know why you have a
colon in front).  I tried it with parentheses but didn't realize I had
to escape them (though I now understand the results of that attempt).

The colon is the vim prompt (helps see that I was speaking vimese)

OK.  It just threw me because in vim I don't see the ":" when doing a "/".

..
Actually, the ideal (as you correctly concluded) was to search for any
lines that contain at least one of each of the four search items, in
unknown sequence.  (double "yuk!")

I've been playing with regex, and it's been a while since I played with
grep.  So with regex fresh (well, *more* fresh), I naturally thought of
it first...

if you stop to think that the 're' in the middle of grep stands for
Regular Expression, then you should have thought of grep first, eh?

:-)   Pehaps, but I haven't used regex much anywhere besides vim.

.. Also, I kinda wanted to be able to see the line in context,
which grep precludes.  But I found a different way to get what I want
with only *one* extra step.   :-)

As mentioned, the chained-grep approach may give false matches,
depending on the actual search data. The painful enumeration of all the
permutations may be the most reliable as well as the clearest expression
of the problem logic.

Well, for my needs, I think the chained grep approach is the best. I realized also that the unmodified file has the equivalent of line numbers. I chain grep that file, find the line "number", and then jump into vim. Then I have all the context, no matter how many lines are necessary for it.

You can always write a script to generate the search pattern. I bet Stu
could even whip one up as a vim macro.

If I get to a point where I would use it a *lot*, then I may look into that.

Probably not as easily done as in emacs (via elisp), I wager.

Especially since I have exactly *zero* familiarity with emacs (or elisp).

Regards,
..jim

Thanks jim.



--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to