Intelligently setting case sensitivity
Vim has a really nice option for setting case sensitivity intelligently. It’s called smartcase, and it makes your search case sensitive if your search pattern uses uppercase characters.
You can enable it with :set ignorecase followed by :set smartcase and disable it with :set nosmartcase.
Work through the checklist below. With smartcase on, a search for needle still matches every case variant — but a search for Needle, with its capital letter, only matches the capitalized ones. Watch the highlights change between the two searches.
1 2 3 4 5
Turn on ignorecase Case insensitive search is the base that smartcase builds on — type :set ignorecase and hit Enter.
Turn on smartcase Now capital letters in a pattern will switch case sensitivity back on — type :set smartcase and hit Enter.
Search in all lowercase Every needle and Needle matches, regardless of case — type /needle and hit Enter.
Jump down to the list of needles The bottom of the demo has a little list of needles — keep pressing n until you land on the first needle in that list.
Search with a capital letter This time only the capitalized Needle lines match — type /Needle and hit Enter to land on the first one below you.
Next: Turn on smartcase
Next: Search in all lowercase
Next: Jump down to the list of needles
Next: Search with a capital letter
Last one — goal check runs when it's done
Nice work!
Up next: Lesson 9 — Operators Motions And Text Objects.