- **Epistemic status:** #seedlings [[Vim]] has the `:subtitute` command that searches a given text string with a regular expression and replaces it with another text string. These are some options: - `:s/foo/bar/g` - Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'. - `:%s/foo/bar/g` - Find each occurrence of 'foo' (in all lines), and replace it with 'bar'. - `:%s/foo/bar/gc` - Find each occurrence of 'foo' (in all lines), and replace it with 'bar' on confirmation. - `:%s/<foo>/bar/gc - Find only whole words that exactly match 'foo' and replace it with 'bar' on confirmation. - `:%s/foo/bar/gci` - Case-insensitive search that finds each occurrence of 'foo' (in all lines), and replace it with 'bar' on confirmation. - `:%s/foo/bar/gci` - Case-sensitive search that finds each occurrence of 'foo' (in all lines), and replace it with 'bar' on confirmation. ## Arguments - `c`: For each match, ask for confirmation - `g`: Stands for global, and it performs a search for all occurrences on the file. - `i`: Case insensitive - `I` Case sensitive --- ## References - Vim Tips Wiki. “Search and Replace.” Accessed June 14, 2022. <https://vim.fandom.com/wiki/Search_and_replace>.