简体   繁体   English

在制表符或终端之间的vim中轻松复制/粘贴

[英]Easy copy/paste in vim between tabs or terminals

What line should I add in my vimrc to easily copy/paste between terminals or between different files/tabs? 我应该在vimrc中添加哪一行以便在终端之间或不同文件/选项卡之间轻松复制/粘贴?

I now have: 我现在有:

" Better copy & paste
set pastetoggle=<F2>
set clipboard=unnamed

I use my vim as Python IDE, never had problems so far, but it doesn't seem to handle copy/paste between 2 different files/tabs. 我将vim用作Python IDE,到目前为止还没有遇到问题,但是它似乎无法处理2个不同文件/选项卡之间的复制/粘贴。

What line should I add? 我应该添加哪一行? What do you use to copy/paste between different terminals or tabs? 您如何在不同的终端或标签之间复制/粘贴?

It is personal preference, but i use the standard: 这是个人喜好,但我使用标准:

"+y
"+p

I like that this works by default and for me, it has became a 'finger macro' that i can type easily and quickly. 我喜欢默认情况下可以使用此功能,对我来说,它已成为我可以轻松快速键入的“手指宏”。 You could assign these to something else if you like but i find this works fine as is. 如果愿意,可以将它们分配给其他对象,但是我发现它可以正常工作。

A vimtip was linked in the below wiki which remaps the sequence to the following: 下面的Wiki中链接了一个vimtip,该维基将序列重新映射为以下内容:

vmap <C-Space> "ay
nmap <C-Space> "aP
imap <C-Space> <C-o>"ap
nmap <C-c> "ayiw

vimwiki explanation: https://vim.fandom.com/wiki/Copy,_cut_and_paste vimwiki解释: https ://vim.fandom.com/wiki/Copy,_cut_and_paste

unlike most text editors, Vim distinguishes between its own registers and the system clipboard. 与大多数文本编辑器不同,Vim区分自己的寄存器和系统剪贴板。 By default, Vim copies to, cuts to, and pastes from its own default register, called the unnamed register ("", also called quotequote) instead of the system clipboard. 默认情况下,Vim复制,剪切和粘贴其默认寄存器,即未命名寄存器(“”,也称为引号),而不是系统剪贴板。

Assuming Vim was compiled with clipboard access, it is possible to access the "+ or "* registers, which can modify the system clipboard. 假设Vim是使用剪贴板访问权限编译的,则可以访问“ +”或“ *”寄存器,这可以修改系统剪贴板。 In this case, one can copy with eg "+y in visual mode, or "+y{motion} in normal mode, and paste with eg "+p. 在这种情况下,可以在视觉模式下使用“ + y”进行复制,而在正常模式下可以使用“ + y {motion}”进行复制,并使用“ + p”进行粘贴。

If your installation of Vim was not compiled with clipboard support, you must either install a package that has clipboard support, or use an external command such as xclip as an intermediary. 如果Vim的安装未使用剪贴板支持进行编译,则必须安装具有剪贴板支持的软件包,或者使用外部命令(例如xclip)作为中介。 See Accessing the system clipboard for detailed information. 请参阅访问系统剪贴板以获取详细信息。

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

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