Cheatsheet Pages / Vim Cheatsheet

How to control case and highlighting when searching in Vim — \c, smartcase, :noh

Search is matching the wrong case, or the screen stays lit up with highlights after you have found what you needed.

Almost every entry was run headless in Vim 9.1 and the resulting file checked; the few entries a tiny build cannot run (system clipboard, persistent undo, the sudo save) were verified against Vim's own documentation instead.

/\cHello        " \c in the pattern: ignore case for THIS search (\C forces case)
:set ignorecase smartcase
                " ignorecase: searches are case-insensitive…
                " …unless smartcase sees an uppercase letter in the pattern
:set hlsearch incsearch
                " hlsearch: highlight all matches   incsearch: jump while you type
:noh            " clear the match highlighting until the next search (:nohlsearch in full)
Vim Cheatsheet one-page card — commands that actually work
The full one-page card — Vim Cheatsheet. Get the complete cheatsheet on GitHub