修复 Vim + Tmux 猛拉/粘贴未命名寄存器 [英] Fix Vim + Tmux yank/paste on unnamed register

查看:36
本文介绍了修复 Vim + Tmux 猛拉/粘贴未命名寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 tmux 会话中使用 vim 时,我无法猛拉或粘贴到未命名的寄存器.转到命名寄存器工作正常,但未命名永远不起作用.

While using vim inside a tmux session I cannot yank or paste to the unnamed register. Going to a named register works fine, but unnamed never works.

错误是:

E353: Nothing in register *

没有 tmux,vim 可以使用我当前的设置正常工作.如何修复它以便我可以使用 y 然后使用 p 而不会出现错误并且不指定寄存器?

Without tmux, vim works fine using my current settings. How do I fix it so I can use y then p without errors and without specifying the register?

推荐答案

从错误信息(Nothing in register *)来看,当你做一个普​​通的? p,您的 Vim 实例正在使用 * register 而不是 未命名的寄存器*.这可能是因为您的 clipboard 选项包括值 unnamed.以这种方式配置时,Vim 将默认使用 * 寄存器而不是未命名的寄存器来进行 yank、delete、change 和 put 操作(即除非您指定另一个带有 " 前缀;例如 "apa 寄存器中放入).

From the error message (Nothing in register *), it appears that when you do a plain? p, your instance of Vim is using the * register instead of the unnamed register*. This is probably because your clipboard option includes the value unnamed. When configured this way, Vim will use the * register instead of the unnamed register for yank, delete, change, and put operations by default (i.e. unless you specify another register with a " prefix; e.g. "ap to put from the a register).

*未命名的寄存器实际上被命名为"(双引号).它只是未命名",您不必命名即可使用它(这是默认设置).IE.您不必说 ""p 从未命名寄存器中放入,只需 p.

*The unnamed register is actually named " (double quote). It is only "unnamed" in the sense that you do not have to name it to use it (it is the default). I.e. you do not have to say ""p to put from the unnamed register, just p.

clipboard 的默认值不包含 unnamed,因此它可能来自您的某些配置(或插件).命令 :verbose set clipboard? 将显示设置当前值的脚本.如果这是在您的配置文件中完成的,那么当您在 tmux 下运行时,您可能不想这样做.例如:

The default value of clipboard does not contain unnamed, so it is probably coming from some bit of your configuration (or a plugin). The command :verbose set clipboard? will show you the script that set the current value. If this is being done in your configuration file, then you might want to not do it when you are running under tmux. E.g:

if $TMUX == ''
    set clipboard+=unnamed
endif

或者,可能有一些方法让 Vim-inside-tmux 的实例访问 GUI 选择/剪贴板(从而使用 * 寄存器和/或 <clipboard 中的代码>未命名).如果您运行的是 Mac OS X,您可能需要查看 my workaround wrapper- 为 tmux 会话中运行的进程启用剪贴板访问.如果您使用的是其他操作系统或 GUI,那么您将需要找出 Vim 通常如何与 GUI 对话以及它为什么不工作(例如,X11 下的 DISPLAY 值错误,可能是由于附加到正在运行的旧会话具有过时值的外壳).

Alternatively, there may be some way to let instances of Vim-inside-tmux access the GUI selection/clipboard (thus work with the * register and/or unnamed in clipboard). If you are running Mac OS X, you may want to look at my workaround wrapper that re-enables clipboard access for processes running inside a tmux session. If you are using some other OS or GUI, then you will need to find out how Vim would normally talk to the GUI and why it is not working (e.g. wrong DISPLAY value under X11, possibly due to attaching to an old session that is running a shell that has an out-of-date value).

这篇关于修复 Vim + Tmux 猛拉/粘贴未命名寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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