- 论坛徽章:
- 0
|
Give the put command, p, to restore the deleted line at the next line
below the cursor. To finish reordering this sentence, you would also
have to change the capitalization and punctuation (with r) to match the
new structure.
Once you delete text, you must restore it before the
next change command or delete command. If you
make another edit that affects the buffer, your
deleted text will be lost. You can repeat the put
over and over, so long as you don't make a new
edit. In Chapter 4, you will learn how to save text
you delete in a named buffer so you can retrieve it
later.
2.3.6.1 Transposing two letters
You can use xp (delete character and put after cursor) to transpose
two letters. For example, in the word mvoe, the letters vo are
transposed (reversed). To correct a transposition, place the cursor
on v and press x, then p. By coincidence, the word transpose helps
you remember the sequence xp; x stands for trans, and p stands for
pose.
There is no command to transpose words. The section "More
Examples of Mapping Keys" in Chapter 7 discusses a short sequence
of commands that transposes two words.
2.3.7 Copying Text
Often you can save editing time (and keystrokes) by copying a
part of your file to use in other places. With the two commands y(for yank) and p (for put), you can copy any amount of text and put
that copied text in another place in the file. A yank command copies
the selected text into a special buffer, where it is held until another
yank (or deletion) occurs. You can then place this copy elsewhere in
the file with the put command.
As with change and delete, the yank command can be combined
with any movement command (yw, y$, 4yy). Yank is most
frequently used with a line (or more) of text, because to yank and
put a word usually takes longer than simply to insert the word.
The shortcut yy operates on an entire line, just as dd and cc do. But
the shortcut Y, for some reason, does not operate the way D and C |
|