I was wondering if there is some way in Vim to navigate through search results by block, where a block is a span of lines, each having an occurrence of the search pattern.
Say, the contents of a buffer is as follows:
Line 1: Pattern
Line 2: Pattern
Line 3: Pattern
Line 4:
Line 5: Pattern
---- No Pattern here ----
Line n+1: Pattern
Line n+2:
Line n+3:
Line n+4: Pattern
Line n+5: Pattern
Then, the command should navigate from Line 1, to Line 5, Line n+1, Line n+4, and so on. It should ignore matches happening in consecutive lines (i.e., within a block) and jump to the next block.
You could you folding for that.
To fold blocks of contiguous lines containing the last searched pattern:
Now you can use regular fold navigation
zj move one fold down, zk move one fold up
zcdd yank the current block into the default register