Vim: How do you efficiently search for text?

Press "n" after you completed a search, then it will repeat the previous action(search).


If the string you search is under the cursor, then you can type * to search for it forward, or # to search for it backwards.


How I usually search is something like;

  1. Press '/'
  2. Enter Search Term
  3. Press Enter
  4. Use 'n' and 'N' to navigate forward and backwards within the search.

Vim keeps a history of your searches, so if you need previous searches you can press '/' and use the UP and DOWN keys or <Ctrl-P> <Ctrl-N> to browse the search history.

You can also use '?' instead of '/' to search backwards.

I also like to use:

set ignorecase smartcase

Now it will only be a case sensitive search if you have uppercase characters in the search string.

Tags:

Vim

Search