search

/ and ?

/ searches forward for a regex, ? searches backward. After the search, press n to jump to the next match and N for the previous — searching is a first-class motion, so d/foo deletes up to the next 'foo'.

/{pattern}<Enter>   ?{pattern}<Enter>  (normal mode)

Variations

Keystroke Effect
/\c{pattern} Force case-insensitive search for this query
/\<word\> Whole-word match
/{pattern}/e Place cursor at END of match, not start
:set hlsearch / incsearch Highlight matches and search as you type

Examples

/TODO<Enter>

Jump to next TODO in file

?function<Enter>

Search backward for 'function'

d/;<Enter>

Delete everything up to the next semicolon

Gotcha

Vim uses its own 'magic' regex flavor — \(...\) for groups, \+ for one-or-more. Prefix with \v for 'very magic' (PCRE-ish) syntax.

Related

← All Vim commands · Vim cheat sheet