#### 4.5.3 Replace

Syntax: `Replace [`string`]`
Abbreviation: `R`

moves to the first match of the most recent find string or regular expression and prompts you for which action to perform. You can choose among:

- replacing the string found with the given string and moving to the next match (‘`Yes`’);
- moving to the next match (‘`No`’);
- replacing the string found with the given string, and stopping the search (‘`Last`’);
- stopping the search immediately (‘`Quit`’);
- replacing all occurrences of the find string with the given string (‘`All`’);
- reversing the search direction (‘`Backward`’ or ‘`Forward`’); this choice will also modify the value of the back search flag. See SearchBack.

`Replace` is mainly useful for interactive editing. `ReplaceOnce`, `ReplaceAll` and `RepeatLast` are more suited to macros.

If no find string was ever specified, you can enter it on the input line. If the optional argument string is not specified, you can enter it on the input line, the default being the last string used. When the last search was a regular expression search, there are some special features you can use in the replace string (see Regular Expressions) . See FindRegExp.

Note that normally a search starts just one character after the cursor. However, when `Replace` is invoked, the search starts at the character just under the cursor, so that you can safely `Find` a pattern and `Replace` it without having to move back.

Warning: when recording a macro with Record, there is no trace in the macro of your interaction with `ne` during the replacement process. When the macro is played, you will again have to choose which actions to perform. If you want to apply automatic replacement of strings for a certain number of times, you should look at ReplaceOnce, ReplaceAll, and RepeatLast.