Niels Kobschätzki wrote:
> I was wondering what the reasoning behind the existence of c,
> r and a is.
> They are all the same but
> c works with move-commands (like cw)
> s works with prefixed numbers (like 4s)
> r doesn't work with anything.
>
> Why where three commands for essentially the same thing once
> introduced? Why not doing everything with r (which is based
> on the word replace) for example?
They are very different and will greatly repay the effort of
learning. One nice feature is that each is repeatable by
pressing . (which repeats the last normal mode command).
On this text:
abc def ghi jkl
def ghi jkl abc
abcdefghijkl
Put the cursor on 'd' in the first line.
Type ceXYZ then press Esc (change to end of word, which enters
insert mode, then insert XYZ, then exit insert mode).
Put the cursor on 'd' in the last line.
Press . to repeat (result: abcXYZ in last line).
Press u twice to undo the two changes and restore the text.
Now try these variations instead of ceXYZ
(do each on 'd' in first line and . in last line):
3sXYZ
rX
Also, r is useful in a visual selection.
In the second line, type 0fgvee
(go to start line, find 'g', visual select, end word, end word).
Then type rX to replace "ghi jkl" with "XXXXXXX".
John
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php