我正在将出现的事件拉MyText
入缓冲区B
:
:g/MyText/yank B
但它总是附加到缓冲区而不是覆盖它。过了一会儿,B
寄存器包含了我之前拉过的所有行。我怎样才能覆盖它而不是附加它?
在 vi 中,我们有“编辑缓冲区”,也就是 Vim 现在所说的缓冲区,和“缓冲区”,现在 Vim 称之为“寄存器”。这样就更清楚了。
注意寄存器是b
,不是B
。b
在这种情况下,您使用寄存器的名称来拉入它:
:yank b
并且您使用大写变体附加到它:
:yank B
Vim 导师并没有真正提到寄存器,参考手册和用户手册都非常清楚所有这些,所以我不确定你在哪里以及如何将它倒退。
:help registers
:
4. Named registers "a to "z or "A to "Z *quote_alpha* *quotea*
Vim fills these registers only when you say so. Specify them as lowercase
letters to replace their previous contents or as uppercase letters to append
to their previous contents. When the '>' flag is present in 'cpoptions' then
a line break is inserted before the appended text.
:help 10.1
:
APPENDING TO A REGISTER
So far we have used a lowercase letter for the register name. To append to a
register, use an uppercase letter.
Suppose you have recorded a command to change a word to register c. It
works properly, but you would like to add a search for the next word to
change. This can be done with:
qC/word<Enter>q
You start with "qC", which records to the c register and appends. Thus
writing to an uppercase register name means to append to the register with
the same letter, but lowercase.
This works both with recording and with yank and delete commands. For
example, you want to collect a sequence of lines into the a register. Yank
the first line with:
"aY
Now move to the second line, and type:
"AY
Repeat this command for all lines. The a register now contains all those
lines, in the order you yanked them.