0

What I want to do is jump to the first instance of character < X > after the cursor.

I already know how to achieve this on the current line, but I was wondering if there was a way to apply this to the whole buffer?

I realize that this can be achieved using the search function /, but that highlights all of the instances in the current buffer. Would I need to disable highlighting on the search in that case?

2

You can use the search feature to achieve this. I.e. if you wanted to find the first f you can do:

/f

followed by the enter key to confirm the search. You can use :nohl to clear the highlighting once you've done that. Vim's search engine is very powerful and can do much more complex searches as well.

This is the easiest method of doing this. If you really don't want to highlight searches you can also use the search() function like so:

:call search('f')

Of course this is much more typing. If this is something you do a lot you can a create a custom command to reduce the the amount of typing, but I feel like that's overthinking things.

See :help / for more info on searching or :help search() for more info on the search function.

  • I was wondering if there's a way to do this without using search, since doing that highlights all of the instances in the current buffer. (I'll update the question to acknowledge this) – Jeeter Jun 13 '17 at 21:31
  • 1
    You can just do :nohl to clear the search if it bothers you that much. – Tumbler41 Jun 13 '17 at 21:32
  • aha, I was always curious if there was a way to do that! Thanks :) – Jeeter Jun 13 '17 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.