PREV Deleting Text UP Text Handling NEXT Search and Replace

4.2.6: Changing Text

<count> r<char>

Replace <count> chars by <char> - no <esc>.

<count> R Overwrite the rest of the line, appending change count - 1 times.
<count> s Substitute <count> chars.
<count> S Change <count> lines.
<count> c<move> Change from begin to endpoint of <count><move>.
<count> cc Change <count> lines.
<count> C The rest of the line and <count> - 1 next lines.
<count> =<move> Reindent the region described by move.
<count> ~ Switch lower and upper cases.
<count> J Join <count> lines (default 2).
:[x,y]s/<pat>/<repl>/<f> Substitute (on lines x through y) the pattern <pat> (default the last pattern) with <repl>. Useful flags <f> are `g' for `global' (i.e. change every non-overlapping occurrence of <pat>) and `c' for `confirm' (type `y' to confirm a particular substitution, else `n' ). Instead of / any punctuation CHAR unequal to <space> <tab> and <lf> can be used as delimiter.

In Emacs, `\&' stands for the last matched expression, so s/[ab]+/\&\&/ will double the string matched by [ab]. Viper doesn't treat `&' specially, unlike Vi: use `\&' instead.

Note: The newline character (inserted as C-qC-j) can be used in <repl>.

:[x,y]copy [z] Copy text between x and y to the position after z.
:[x,y]t [z] Same as :copy.
:[x,y]move [z] Move text between x and y to the position after z.
& Repeat latest Ex substitute command, e.g. :s/wrong/right.
C-c / Toggle case-sensitive search. With prefix argument, toggle vanilla/regular expression search.
#c<move> Change upper-case characters in the region to lower-case.
#C<move> Change lower-case characters in the region to upper-case.
#q<move> Insert specified string at the beginning of each line in the region
C-c M-p and C-c M-n In Insert and Replace states, these keys are bound to commands that peruse the history of the text previously inserted in other insert or replace commands. By repeatedly typing C-c M-p or C-c M-n, you will cause Viper to insert these previously used strings one by one. When a new string is inserted, the previous one is deleted.

In Vi state, these keys are bound to functions that peruse the history of destructive Vi commands. See Viper Specials, for details.

PREV Deleting Text UP Text Handling NEXT Search and Replace