Reputation: 1492
I would like to see if something already exists in the current file (e.g. a certain import) by making a custom Vim function. Just an idea, is it possible to use the response from searching for something with /
?
Upvotes: 2
Views: 738
Reputation: 820
You can use search()
. Specifying 'nw'
in flags (second argument); n
will ensure the cursor stays in place, and w
ensures you search the whole file, not just a portion of it. You can then check the function's result; if it's non-zero, then something matched your pattern.
Upvotes: 4