Next: Modifying Commands, Previous: Motion Commands, Up: Vi Commands [Contents][Index]

### 2.8 Searching and Replacing

Following commands are available for searching and replacing.

`/ string RET`

  Search the first occurrence of the string string forward starting from point. Given a count n, the n-th occurrence of string will be searched. If the variable `vip-re-search` has value `t` then regular expression search is done and the string matching the regular expression string is found. If you give an empty string as string then the search mode will change from vanilla search to regular expression search and vice versa (`vip-search-forward`).

`? string RET`

  Same as `/`, except that search is done backward (`vip-search-backward`).

`n`

  Search the previous search pattern in the same direction as before (`vip-search-next`).

`N`

  Search the previous search pattern in the opposite direction (`vip-search-Next`).

`C-s`

  Search forward incrementally. See GNU Emacs Manual for details (`isearch-forward`).

`C-r`

  Search backward incrementally (`isearch-backward`).

`R string RET newstring`

  There are two modes of replacement, vanilla and regular expression. If the mode is vanilla you will get a prompt ‘`Replace string:`’, and if the mode is regular expression you will ge a prompt ‘`Replace regexp:`’. The mode is initially vanilla, but you can toggle these modes by giving a null string as string. If the mode is vanilla, this command replaces every occurrence of string with newstring. If the mode is regular expression, string is treated as a regular expression and every string matching the regular expression is replaced with newstring (`vip-replace-string`).

`Q string RET newstring`

  Same as `R` except that you will be asked form confirmation before each replacement
  (`vip-query-replace`).

`r ch`

  Replace the character point is looking at by the character ch. Give count, replace that many characters by ch (`vip-replace-char`).

The commands `/` and `?` mark point before move, so that you can return to the original point by `` ``.

Next: Modifying Commands, Previous: Motion Commands, Up: Vi Commands [Contents][Index]