首页 > 代码库 > vim摘要

vim摘要


The "." command is one of the most simple yet powerful commands in Vim. It
repeats the last change. For instance, suppose you are editing an HTML file
and want to delete all the <B> tags. You position the cursor on the first <
and delete the <B> with the command "df>". You then go to the < of the next
</B> and kill it using the "." command. The "." command executes the last
change command (in this case, "df>"). To delete another tag, position the
cursor on the < and use the "." command.
f<
df>
f<
.
f<
.
find first <
delete to >
find next <
repeat df>
find next <
repeat df>
To <B>generate</B> a table of <B>contents ~
???>
??>
?????????>
???>
?????????????>
??>
The "." command works for all changes you make, except for the "u" (undo),
CTRL?R (redo) and commands that start with a colon (:).
Another example: You want to change the word "four" to "five". It appears
several times in your text. You can do this quickly with this sequence of
commands:
/four<Enter>
cwfive<Esc>
n
.
n
.
find the first string "four"
change the word to "five"
find the next "four"
repeat the change to "five‘
find the next "four"
repeat the change
etc.
================================