Step 6 of 7

8. Searching

Case insensitive search

By default, Vim searches are case sensitive. A search like /A will only match A characters, not a. This behavior isn’t always what you want.

Vim lets use override this with the ignorecase option. Use the command :set ignorecase to enable it, and :set noignorecase to disable it. With this turned on, Vim searches won’t be case sensitive.

Work through the checklist below. There’s a few NEEDLE strings hidden among the HAYSTACK strings in the editor, but the NEEDLE strings are capitalized strangely, so you won’t be able to find them with just /NEEDLE. Enable the ignorecase option first, then search for needle to find them all.

  1. Turn on ignorecase Searches stop caring about case from here on — type :set ignorecase and hit Enter.
  2. Search in lowercase Every strangely-capitalized NEEDLE now matches, starting with the intro lines at the top — type /needle and hit Enter.
  3. Jump to the first hidden needle The first one is buried over 1,000 lines down — keep pressing n until you reach it.
  4. Jump to the second The next press lands on the second one — press n.
Turn on ignorecase Searches stop caring about case from here on — type :set ignorecase and hit Enter.

Next: Search in lowercase

Loading editor…