Vim’s Search Tips – Mosky’s Notes
The Magic
Flag
Mode
Special Chars
\V
very nomagic
\
\M
nomagic
\ ^ $
\m
magic (default) = BRE + ~
\ * ^ $ . [] ~
\v
very magic
All ASCII chars except [0–9a–zA–Z_].
  • ~: the latest substitute string, not the pattern.
  • Must be `/\Vput first`.

Incsearch Shortcuts

  • CTRL-G: Go the next match.
  • CTRL-T: Go the previous match.
  • CTRL-L: Add one char from the current match.

Search & Search Offset

/pattern<CR>
/pattern/1<CR> " go next line of the match, or
//1<CR> " use the // repeats the last search instead

/pattern<CR>
//e<CR> " patter*n*
//e1<CR> " patte*r*n
//s<CR> " *p*attern
//s1<CR> " p*a*ttern
//s-1<CR> " * *pattern

Search Twice

/class/;/ClassName

Search With Yank Register
   
yaw
/<C-R>"

Search Without Escaping Slash

?/usr/bin          " or
:let @/='/usr/bin'

Search Case-Insensitively and Case-Sensitively

/\capple " \c = insensitively
/\CApple " \C = sensitively (default)

Search Smartly