Name
Substitution
:[addr1[,addr2]]s/pattern/replacement/[cgp]
Replace the text matched by pattern with replacement on every line in the address range. If no address range is given, the current line is used. Each address may be a line number, or a regular expression. If addr1 is supplied, substitution begins on that line number (or the first matching line), and continues until the end of the file, or the line indicated (or matched) by addr2. There are also a number of address shortcuts, which are described in the following tables.
Substitution options
Option | Meaning |
|---|---|
| Prompt before each substitution. |
| Replace all matches on a line. |
| Print line after substitution. |
Address shortcuts
Address | Meaning |
|---|---|
| Current line. |
| Last line in file. |
| Entire file. |
| Position |
| Next line matched by pattern. |
| Previous line matched by pattern. |
| Next line matched by the last search. |
| Previous line matched by the last search. |
| Next line where the last substitution pattern matched. |