Vi Search and Replace
How to do search and replace in Vim.
Search for “foo” and replace it with “bar” in the current line. Use :s
<pre lang="bash">
:s/foo/bar/g
Search for “foo” and replace it with “bar” in the entire document. Use :%s
<pre lang="bash">
:%s/foo/bar/g
You can also pipe instead of forward slash. Useful if your search contains a /.
<pre lang="bash">
:%s|foo/|bar|g