如何追加到剪贴板

发布于 2024-11-15 02:11:51 字数 227 浏览 4 评论 0原文

我知道如何复制到剪贴板,但如何附加到它?

我在我的代码中使用它:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-11-22 02:11:51

使用:

let @+ = @+ . my_expression

或更短:

let @+ .= my_expression

参考::help :let.=

use:

let @+ = @+ . my_expression

or shorter:

let @+ .= my_expression

Reference: :help :let.=

安稳善良 2024-11-22 02:11:51

如果您不使用宏,那么也可能值得查看寄存器:help registers 令人兴奋。

简而言之,还有 26 个额外的“可自定义剪贴板”,称为寄存器,您可以在其中存储从 a 开始到 z 的文本。

您可以在命令模式下通过点击 " 向寄存器添加文本,命名寄存器(例如 f),然后键入所需的“动作”选择文本。

注意:我们在这里使用名为 f 的寄存器,因为它可能位于您的左手食指下方。 , f 被选中只是因为它很方便。 可以将 f 替换为 auz 或任何内容。


如果您愿意, at [T]):

初始文件状态

This is my first line.
[T]his is my second line. 
This is my third line.

在命令模式下键入 "fyy 以用一行 (yy) 填充寄存器。

  • 输入p(*见下文)立即从默认寄存器粘贴它。
  • 输入 "f 选择 f 寄存器,然后输入 p 直接从 f 寄存器粘贴。现在 f 和 default 是一样的。

因此,输入 "fyyp 的结果与输入 yyp 的结果完全相同默认剪贴板。

结果

This is my first line.
This is my second line. 
[T]his is my second line. 
This is my third line.

附加到寄存器:

使用大写字母附加到现有寄存器。

在上面的示例中,粘贴后,按 j 向下一行,然后按 "Fyy。然后输入 p您已附加“这是我的第三行。”到

结果

This is my first line.
This is my second line. 
This is my second line. 
This is my third line.
This is my second line. 
[T]his is my third line.

(使用小写) 。 >f 会清除 f 的内容并最终只保留“这是我的第三行。”)

为什么在拉入 f 后,p 会立即粘贴寄存器 f 中的内容?因为您的默认寄存器保存了指向最后一个选择的指针,并且显然不仅仅保存您添加到 f 的内容,而是在追加时提取 f 中的所有内容。在第一种情况下,“输入 "fyy"fp 的结果与使用默认剪贴板输入 yyp 的结果完全相同”可能更具说明性。

但是,如果您现在要yy在默认寄存器中添加一个新行,则可以点击“f来选择f寄存器并然后 p 粘贴之前的值。

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 through z.

You add text to a register in command mode by hitting ", naming the register (say f), 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 replace f with a or u or z or whatever throughout if you wanted.


Copying with a register (cursor at [T]):

Initial File State

This is my first line.
[T]his is my second line. 
This is my third line.

Type "fyy in command mode to fill the register with one line (yy).

  • Type p (* see below) to immediately paste it from the default register.
  • Type "f to pick the f register and then p to paste from the f register directly. Right now f and default as the same.

So the result of typing "fyyp is exactly the same as having typed yyp with the default clipboard.

Result

This is my first line.
This is my second line. 
[T]his is my second line. 
This is my third line.

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 type p to paste. You've appended "This is my third line." to f's contents.

Result

This is my first line.
This is my second line. 
This is my second line. 
This is my third line.
This is my second line. 
[T]his is my third line.

(Using a lower case f would have cleared out f's contents and ended up with it only holding "This is my third line.")

Why does p paste what's in register f immediately after you yanked into f? Because your default register holds a pointer to the last selection, and apparently doesn't simply hold what you added to f, but pulls everything that's in f when you append. It might be more expository to say, in the first case, "the result of typing "fyy"fp is exactly the same as having typed yyp with the default clipboard."

But if you were now to yy a new line into the default register, you can hit "f to select the f register and then p to paste that previous value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文