I often forget about the "newer" searching features in VIM's regular expression quiver: line aware regular expressions. Today, I needed to detect when certain requests had occured twice in a row without any response in between.
First, I grepped the patterns important:
grep "REQ\|RSP" file.txt | vim -
Then I searched for two REQ's in a row:
/REQ.*\_..*REQ
Tada! Wow, that was just so easy.
I haven't played with these kinds of regexps enough to know if you can extend it to say three lines in a row or say two lines with the pattern, and one without, etc. But, I expect it is quite possible with a little work.