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