如何在 Vim 的终端模式下复制粘贴? [英] How to copy and paste in Vim's terminal mode?

查看:92
本文介绍了如何在 Vim 的终端模式下复制粘贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常想将文本从 :terminal 窗口复制到普通文本缓冲区.目前我exit shell 会话并从历史记录中复制.

I often want to copy text from a :terminal window to a normal text buffer. At the moment I exit the shell session and copy from the history.

必须有更好的方法.

推荐答案

复制

要从终端窗口复制,请按 CTRL-W N(这是大写的 N)1CTRL-\ CTRL-N(这是不是大写的 N)进入正常模式.从那里你可以使用所有常用的 vim 命令来复制和粘贴内容.

Copy

To copy from a terminal window press CTRL-W N (This is a capital N)1 or CTRL-\ CTRL-N (this is not a capital N) to get into normal mode. From there you can use all usual vim commands to copy and paste stuff.

进入插入模式会让你回到你的外壳.

Entering insert mode will drop you back to your shell.

要从寄存器粘贴到终端窗口,您必须处于终端作业(插入")模式.

To paste from a register into the terminal window you have to be in Terminal-Job ("insert") mode.

CTRL-W " 后跟寄存器.

:help Terminal-mode 告诉我们:

当作业运行时,终端的内容由工作.这包括光标位置.键入的键被发送到作业.终端内容可以随时更改.这称为终端作业模式.

When the job is running the contents of the terminal is under control of the job. That includes the cursor position. Typed keys are sent to the job. The terminal contents can change at any time. This is called Terminal-Job mode.

使用 CTRL-W N(或 'termkey' N)切换到终端正常模式.现在终端窗口的内容由 Vim 控制,作业输出为暂停.CTRL-\ CTRL-N 也一样.

Use CTRL-W N (or 'termkey' N) to switch to Terminal-Normal mode. Now the contents of the terminal window is under control of Vim, the job output is suspended. CTRL-\ CTRL-N does the same.

[...]

在终端正常模式下,您可以使用通常的 Vim 移动光标命令、可视化标记文本、猛拉文本等.但您无法更改缓冲区的内容.将启动插入模式的命令,例如'i' 和 'a',返回终端作业模式.

In Terminal-Normal mode you can move the cursor around with the usual Vim commands, Visually mark text, yank text, etc. But you cannot change the contents of the buffer. The commands that would start insert mode, such as 'i' and 'a', return to Terminal-Job mode.

有关终端窗口中更有用的命令,请参阅 :h terminal-typing.

See :h terminal-typing for more useful commands in terminal windows.

1不幸的是vim帮助并没有告诉你它是一个大写的N,我保留了原来的符号

这篇关于如何在 Vim 的终端模式下复制粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆