| pd | Index Level | ru |
| Syntax |
r
r{#lines}/old.string/new.string{/}{start.col{-end.col}} ru{#lines}/old.string/new.string{/}{start.col{-end.col}} |
| Category | Editor |
| Type | Command |
| Description |
replaces the current line, or replaces a string of characters within the current line, or replaces a string of characters within a specific range of lines.
Only the first occurrence of the string referenced in "old.string" is replaced with the string referenced in "new.string". The "ru" form replaces all occurrences. If the "#lines" parameter is specified, the line pointer is incremented accordingly. An "r" command, followed by a <return>, allows the replacement of an entire line. Entering a <return> at the first position of the line returns control to the editor command prompt and the line remains unchanged. The "start.col" and "end.col" parameters respectively indicate the beginning and ending column ranges in which strings are eligible for replacement. See the "c" command for determining column ranges. If the "old.string" parameter is null, the "new.string" parameter is inserted at the beginning of the line. If the "new.string" parameter is null and the "old.string" parameter is found, the "old.string" parameter is deleted from the line. Multiple replacements may be performed on a line without "flipping" the buffers with the "f" command. Wild cards: The "up-arrow" (^) character is used as a "wildcard" search character within the string parameter, for replacing known and sometimes unknown strings within strings. It matches any character. Note that the up-arrow character is a normal character, not a control character. See the example: .r/^^^//<return>. See also the "^" command. Using attribute marks in a replace: The <ctrl>+{shift}^ represents an attribute mark in the editor. Used with the replace command, it has the effect of terminating the line. See the example: .r/abc/^<return> below. |
| Options | |
| See Also | error messages ru editor wildcards ^ c |
| Example |
.r<return>
nnn _ Positions cursor at the beginning of line "nnn" for replacement of the entire line. A subsequent <return> leaves the line intact. .r10<return> Positions cursor at the beginning of each of the next ten lines for entire line replacement. .r/^^^//<return> Replaces the first 3 characters (wildcards, or "regular" up-arrows) of the current line with null. (i.e. Deletes first three characters). .r/abc/^<return> Replaces the first occurrence of the string, "abc", with an attribute mark (<ctrl> or <ctrl>+<shift>^), terminating the line prior to the string, abc. .r10//abc<return> Places the string, "abc" at the beginning of the next ten lines. .r10/abc/xyz<return> Replaces the first occurrence of the string, "abc", with the string "xyz" in the current and the next nine lines. .ru10/abc/xyz<return> Replaces all occurrences of the string, "abc", with the string, "xyz", in the current and next nine lines. .r10/abc/xyz/5-9<return> Replaces the first occurrence of the string, "abc", with the string "xyz", in the current and next nine lines, when the string is found in column positions 5 through 9. .ru/^//<return> Replaces all characters on the current attribute with "null", leaving the current attribute intact, but empty. .ru999/ / /<return> Replaces every occurence of two spaces with one space, from the current line through the end of the item. |
| Warnings | When using column ranges (see the "c" command), the "r" command only works if there is data in the attribute and it occurs within the specified column position, or range of positions. It is not possible to replace using a column range beyond the end of the attribute. |
| Compatibility | D3 7.0 AP R83 |
| pd | Index Level | ru |