Move query-checking logic to search.js

The vim mode was making sensible use of a searchcursor with
a match-everything regexp as cursor.

Issue #2259