11

每当我从 tmux 缓冲区复制某些内容(通常使用鼠标)并稍后将其粘贴到 ViM 中时,内容都会被截断。最后一次尝试只给了我复制的完整块的大约 750 字节。

这是在 Mac 上的 iTerm 中。

4

5 回答 5

3

一定要从 tmux 缓冲区粘贴

我有同样的问题,并且粘贴步骤错误。我遇到了这个帖子

我试图做的是简单地使用 ctrl-v 从系统剪贴板粘贴(正如您在问题中解释的那样,它有效,但只是部分有效)。

相反,从 tmux 缓冲区粘贴使用ctrl-b ]可以正确完成工作。

于 2014-05-28T15:22:04.673 回答
1

我在使用 tmux 1.8、iTerm2 和reattach-to-user-namespace. 我遇到了一个解决问题的 tmux 配置绑定:它显式地将最后一个缓冲区选择复制到剪贴板:

bind-key q run "tmux save-buffer - | reattach-to-user-namespace pbcopy"

将其放入您的~/.tmux.conf, 然后C-b q在选择后将所有内容拉入剪贴板。

于 2014-07-26T17:38:22.157 回答
1

问题解决了。几个指点。

  1. reattach-to-user-namespace不需要。只是pbcopy
  2. 经测试tmux 2.3
  3. 诀窍是让MouseDragEnd1Pane事件触发pbcopy
  4. 使用iTerm2这意味着鼠标支持正常工作。从tmux v2.1set-option -g mouse on是必需的。
  5. 您不需要 vi 复制模式。只要确保MouseDragEnd1Pane绑定如下

这是我的脱衣舞~/.tmux.conf

# --------------------------------
# Turn on the Mouse Support - defaults seem good
# --------------------------------
set-option -g mouse on
# when we finish "selecting" send it to pbcopy (and into the OS X buffer)
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy"

# --------------------------------
# Use vim keybindings in copy mode
# --------------------------------
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
# You enter with C-b [ and then "v" - then normal keypresses to "highlight"
# .. [Enter] or "y" will select (because of below bindings)
bind-key -t vi-copy v begin-selection
#
# 'y'ank will send the selection to the OS X buffer
bind-key -t vi-copy y            copy-pipe "pbcopy"

# --------------------------------
# Update default binding of `Enter` to also use Send the selection to OS X buffer
# --------------------------------
unbind   -t vi-copy Enter
bind-key -t vi-copy Enter        copy-pipe "pbcopy"

# selecting can now be done with
#  hilighting with a mouse
#  selecting with C-b [ v .. now vi mode for selecting text
#
# pasting  can now be done with
# ⌘ - V
# C-b ]
于 2017-09-13T13:57:43.327 回答
0

我在这里回答了一个类似的问题。这里有几件可能会影响你:

  1. 终端
  2. tmux 设置
  3. 操作系统

如果您尝试从系统缓冲区粘贴并获得此行为,那么您的终端中可能存在一个限制,它会截断 tmux 可以设置的数据大小。解决方案(在 tmux 2.6+ 中)是使用类似的东西:

# disable built-in setting of system clipboard
set-option -g set-clipboard off
# use external utility for setting system clipboard
# on Linux - xclip (+ssh display forwarding for remote machines)
# on osx - pbcopy
# on cygwin - cat > /dev/clipboard
# on Windows Subsystem for Linux (WSL) - clip.exe
# copy-pipe-* commands also copy to the tmux clipboard
# y yanks to clipboards but stays in copy mode
bind -T copy-mode-vi y send-keys -X copy-pipe "xclip -in -selection clipboard"
# Remove default handling
unbind -T copy-mode-vi Enter
# Enter yanks to clipboards then exits copy mode
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
于 2018-05-06T17:31:35.503 回答
0

要在没有鼠标的情况下复制到 Vim,您可以将tmux paste-buffer命令输出直接粘贴到您正在编辑的文件中。

noremap <leader>p :r !tmux paste-buffer<cr>

将其保存在您的vimrc.

\它将+映射p为从缓冲区粘贴。

默认为<leader>反斜杠 ( \)。

但是您可以通过设置将其更改为您喜欢的任何其他键 (*):

let mapleader="\<Space>"

例如。


(*) 在 Vim 的范围内,也就是说。

于 2017-06-10T16:40:00.600 回答