修复Vim + Tmux的抽签/粘贴在未命名的注册
在tmux会话中使用vim的时候,我不能将其拖放或粘贴到未命名的寄存器中。 去一个命名的注册工作正常,但未命名从来没有工作。
错误是:
E353: Nothing in register *
没有tmux,vim可以正常使用我的当前设置。 我如何解决它,所以我可以使用y然后p没有错误,没有指定注册?
从错误信息(无论Nothing in register *
),看来,当你做一个平原? p
,你的Vim实例使用*
寄存器而不是未命名的寄存器 * 。 这可能是因为您的clipboard
选项包含unnamed
的值。 当以这种方式进行configuration时,Vim将使用*
寄存器而不是未命名的寄存器来进行延迟,删除,更改以及默认放置操作(即除非指定另一个带有"
前缀"ap
a
寄存器;例如"ap
将从寄存器中放入) 。
*未命名的寄存器实际上被命名为"
(双引号)”,它只是“未命名”的意思,你不必命名它来使用它(这是默认的),即你不必说""p
从无名的登记册,只是第一p
。
clipboard
的默认值不包含unnamed
,所以它可能来自你的一些configuration(或一个插件)。 命令:verbose set clipboard?
会显示设置当前值的脚本。 如果这是在你的configuration文件中完成的,那么你可能不想在tmux下运行 。 例如:
if $TMUX == '' set clipboard+=unnamed endif
或者,可能有一些方法让Vim-inside- tmux的实例访问GUIselect/剪贴板(因此可以使用*
寄存器和/或在clipboard
unnamed
)。 如果您正在运行Mac OS X,则可能需要查看我的解决方法包装程序 ,该程序包在tmux会话中运行的进程重新启用剪贴板访问。 如果您正在使用其他操作系统或GUI,那么您将需要了解Vim如何通常与GUI交谈,以及为什么它不工作(例如X11下的DISPLAY值错误,可能是由于附加到正在运行的旧会话一个具有过时值的shell)。
下面是在vim / tmux / osx中对我有用的东西:
- 安装自制软件
- 安装重新连接到用户名称空间:
brew install reattach-to-user-namespace
- 在.vimrc中:
set clipboard=unnamed
- 告诉tmux使用系统剪贴板:在.tmux.conf中:
set-option -g default-command "reattach-to-user-namespace -l bash"
reattachset-option -g default-command "reattach-to-user-namespace -l bash"
来源: https : //coderwall.com/p/j9wnfw
fakeclip插件使得剪贴板寄存器在许多terminal中按照预期行事,并且支持tmux / screen。 你在用吗? 它可能会解决您的问题。
此外,您可能对此提示感兴趣…这不适用于您的问题,但相关。 根据您运行tmux的系统/terminaltypes,您可能需要在.tmux.conf
一些调整。 例如, .tmux.conf
是OS X上我的.tmux.conf
的摘录(注释中有一些说明):
# To use pbcopy and pbpaste on OS X, get this wrapper and install # git clone https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git # cd tmux-MacOSX-pasteboard/ # make reattach-to-user-namespace # mv reattach-to-user-namespace /usr/local/bin # After installing, the default command can be reset to use the 'reattach-to-user-namespace' # wrapper that was compiled/installed as descripted above. set -g default-command "reattach-to-user-namespace -l /bin/bash" # #Next, create Ctrl-c and Ctrl-v mappings bind Cc run "tmux save-buffer - | reattach-to-user-namespace pbcopy" bind Cv run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"
迟到的答案,但也可能是你的.tmux.conf
包含以下行:
set -g set-clipboard off
结合一个.vimrc
包含
set clipboard=unnamed
这将导致vim尝试使用不存在的剪贴板。