Created
August 25, 2012 17:31
-
-
Save VincentVetsch/3468234 to your computer and use it in GitHub Desktop.
VIM: Search and Replace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:%s/foo/bar/g | |
Find each occurrence of 'foo', 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. | |
:%s/foo/bar/gci | |
Change each 'foo' (case insensitive) to 'bar'; ask for confirmation. | |
This may be wanted after using :set noignorecase to make searches case sensitive (the default). | |
:%s/foo/bar/gcI | |
Change each 'foo' (case sensitive) to 'bar'; ask for confirmation. | |
This may be wanted after using :set ignorecase to make searches case insensitive. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment