Skip to content

Instantly share code, notes, and snippets.

@tadone
Created October 6, 2017 12:33
Show Gist options
  • Save tadone/a553e5920680acef9af1dfdae96af420 to your computer and use it in GitHub Desktop.
Save tadone/a553e5920680acef9af1dfdae96af420 to your computer and use it in GitHub Desktop.
Search and replace
:%s/foo/bar/g
Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.
:s/foo/bar/g
Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
:%s/foo/bar/gc
Change each 'foo' to 'bar', but ask for confirmation first.
:%s/\<foo\>/bar/gc
Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment