7.A.3: Saving and Exiting | 7: Editing Files | 7.A.1: Moving in vi |
Now that you've opened a file with vi, let's edit it. First
notice that at the end of the file there is a line with NAME
and DATE
in it. Try changing these to your name and today's
date.
One way to change text in vi is to: delete the old text, and then, insert the new text. (Some people find it easier to insert the new text before deleting the old.)
i
.
[Escape]
key.
x
dw
dd
u
U
Other useful commands for editing are:
Y [Ret] | yank (copy) the current line |
yw [Ret] | yank (copy) next word |
P | put (paste) last thing yanked after cursor |
P
, the text get put there. Try these commands a few times with the sample file; it takes some getting used to, but it can be real fast. We will finish our brief introduction to vi with saving your work and exiting vi.
7.A.3: Saving and Exiting | 7: Editing Files | 7.A.1: Moving in vi |