繁体   English   中英

Vim:将所选文本拖入缓冲区并覆盖该缓冲区

[英]Vim: Yank selected text into buffer and overwrite that buffer

我将MyText的出现拉入缓冲区B

:g/MyText/yank B

但它总是附加到缓冲区而不是覆盖它。 过了一会儿, B寄存器包含了我之前拉过的所有行。 我怎样才能覆盖它而不是附加它?

所以让我们明确一点, b是一个寄存器,而不是一个“缓冲区”。

请注意,寄存器是b ,而不是B 在这种情况下,您使用寄存器的名称b来拉它:

:yank b

并且您使用append的大写变体:

: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.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM