Setup VIM Copy Mode in Tmux

更新時間:2022年2月10日 @Mane

吐槽:tmux自帶的複製粘貼模式真的好難用,按錯了好多次,有時候習慣了vim大法換到tmux卻不知道按什麽,在網上搜索了一段時間找到了這篇文章,還好tmux内置的複製器支持vim的按鍵。

Edit ~/.tmux.conf this file.

apt -y install xclip

配置文件如下:GLIST

setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 
bind P paste-buffer
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

set -g mouse on
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

以前是:

  1. Enter ‘copy mode’ by pressing CTRL+b, [.

  2. Use the arrow keys to go to the position from where you want to start copying. Press CTRL+SPACE to start copying.

  3. Use arrow keys to go to the end of text you want to copy. Press ALT+w or CTRL+w to copy into Tmux buffer.

  4. Press CTRL+b, ] to paste in a possibly different Tmux pane/window.

Source

現在是:

  1. Enter ‘copy mode’ by pressing CTRL+b, [.

  2. Yeah, you enter the vim Copy mode just use the key like in vim.

  3. Press CTRL+b, ] to paste in a possibly different Tmux pane/window.

Comments