Search And Replace In Neovim And Vim
## Everywhere in the file
Code
:%s/foo/bar/g
## On the current line
Code
:s/foo/bar/g
## Change on current line and next two lines (+2)
Code
:.,+2s/foo/bar/g
Change in each line starting with 'baz'.
Code
:g/^baz/s/foo/bar/g
## In all open tabs
Code
:tabdo %s/foo/bar/g
## Change only on specific lines
Code
:5,12s/foo/bar/g
## Change all lines from mark `a` to mark `b` inclusive.
Code
:'a,'bs/foo/bar/g
## Change from the current line (.) to the last line ($) inclusive.
Code
:.,$s/foo/bar/g