Skip to content

Search and Replaceλ︎

Neovim has several built-in commands to search for patterns in the current buffer and quickfix list can be used to run commands across all the files in a project.

Additional tools that work across all the files in a project:

multiple cursors for in-place editing within a buffer

/ searches through the current buffer, prompting for a pattern to search.

Symbol highlight and dot repeat

# on a word highlights each occurrence in the buffer, n and N to jump backward and forward for each instance.

Change the current occurrence (e.g. cw followed by new word)

Use . to repeat the change after jumping to the next instance.

Substitute commandλ︎

Use the :substitute (:s) to replace all occurrences of the current-pattern with the new pattern within the buffer.

Replace using substitute command

:%s/current-pattern/new-pattern/g

Add the c option to confirm each replacement

:substitue neovim command examples

Project search and replaceλ︎

Use search to populate the Neovim quickfix list and change occurrences across all the files in the current project, e.g.:

Search word and replace across project using quickfix list

Space f w to search for the supplied word or pattern

Ctrl q opens the search results in quickfix list

Use :cdo command to search and replace in the quickfix list

:cdo %s/current-pattern/new-pattern/g

Including the c option to confirm each replacement