如何追加到剪贴板
我知道如何复制到剪贴板,但如何附加到它?
我在我的代码中使用它:
let @+ = my_expression
但这会覆盖剪贴板。
我知道我可以使用寄存器 az 附加到:
let @B = my_expression
附加到寄存器 b,但是当我想附加到剪贴板时该怎么办?
I know how to copy to the clipboard but how can I append to it?
I use this in my code:
let @+ = my_expression
but that overwrites the clipboard.
I know that I can use the registers a-z to append to:
let @B = my_expression
which appends to register b, but what do I when I want to append to the clipboard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用:
或更短:
参考:
:help :let.=
use:
or shorter:
Reference:
:help :let.=
如果您不使用宏,那么也可能值得查看寄存器。
:help registers
令人兴奋。简而言之,还有 26 个额外的“可自定义剪贴板”,称为寄存器,您可以在其中存储从
a
开始到z
的文本。您可以在命令模式下通过点击
"
向寄存器添加文本,命名寄存器(例如f
),然后键入所需的“动作”选择文本。注意:我们在这里使用名为
f
的寄存器,因为它可能位于您的左手食指下方。 ,f
被选中只是因为它很方便。 可以将f
替换为a
或u
或z
或任何内容。如果您愿意, at [T]):
初始文件状态
在命令模式下键入
"fyy
以用一行 (yy
) 填充寄存器。p
(*见下文)立即从默认寄存器粘贴它。"f
选择f
寄存器,然后输入p
直接从f
寄存器粘贴。现在f
和 default 是一样的。因此,输入
"fyyp
的结果与输入yyp
的结果完全相同默认剪贴板。结果
附加到寄存器:
使用大写字母附加到现有寄存器。
在上面的示例中,粘贴后,按
j
向下一行,然后按"Fyy
。然后输入p
您已附加“这是我的第三行。”到结果
(使用小写
) 。 >f
会清除f
的内容并最终只保留“这是我的第三行。”)If you're not macro-ing, it's probably worth checking out registers as well.
:help registers
was mind-blowing.In an oversimplified nutshell, there are 26 additional "customizable clipboards", called registers, where you can store text, starting with
a
and going throughz
.You add text to a register in command mode by hitting
"
, naming the register (sayf
), and then typing the "motion" you want to select text.NOTE: We're using the named
f
register here b/c it's probably under your left index finger. That is,f
is picked just b/c it's handy. You could replacef
witha
oru
orz
or whatever throughout if you wanted.Copying with a register (cursor at [T]):
Initial File State
Type
"fyy
in command mode to fill the register with one line (yy
).p
(* see below) to immediately paste it from the default register."f
to pick thef
register and thenp
to paste from thef
register directly. Right nowf
and default as the same.So the result of typing
"fyyp
is exactly the same as having typedyyp
with the default clipboard.Result
Appending to a register:
Use the capital letter to append to your existing register.
In the above example after pasting, press
j
to go down a line and then"Fyy
. Then typep
to paste. You've appended "This is my third line." tof
's contents.Result
(Using a lower case
f
would have cleared outf
's contents and ended up with it only holding "This is my third line.")