normal·mode
~ / search
9

Search & Patterns

Jump anywhere by typing what you see, then bend the pattern to your will: whole words, case, very magic regexes, match boundaries, offsets, and gn to edit match after match.

  1. 01

    Search: / ? n and N

    Type what you want to reach, press Enter, then hop between matches.

    /{pattern}<CR>?{pattern}<CR>nN/<CR>?<CR>nvim
  2. 02

    Search as a motion: d/ c/ d?

    Any search can end an operator, even several lines away.

    d/{pattern}<CR>c/{pattern}<CR>d?{pattern}<CR>y/{pattern}<CR>
  3. 03

    Whole words: * # g* and \< \>

    Search for the word under the cursor, and only whole words.

    *#g*g#\<\>:%s//{new}nvim
  4. 04

    Case: ignorecase, smartcase, \c and \C

    Decide whether "Note" and "note" are the same, per search or for good.

    \c\C:set ignorecase:set smartcase:s/{pat}/{new}/invim
  5. 05

    Very magic \v, very nomagic \V

    Write regexes without a forest of backslashes, or search text exactly as written.

    \v\V\d \w \s \x \a\u \l\1/<Up>/<Down>nvim
  6. 06

    Offsets and match edges: /e, \zs, \ze

    Land on the end of a match, past it, below it, or on just part of it.

    /{pat}/e/{pat}/e+{n}/{pat}/s-{n}/{pat}/+{n}//e\zs\ze
  7. 07

    gn: edit match after match

    Change, delete or skip each match in turn, and count them.

    gngNcgndgn:%s/{pat}//gnnvim
outside the editor the page is in normal mode: ? keymaps · / find · : commandsfound this useful? ☕ support it ·credits · source · not affiliated with Vim or Neovim