tmux有面板的概念,這導致普通終端下的ctrl+shift+C的模式復制出來的文本會串行。如果面板只有一列當然沒有問題,但當面板有多列時,復制就會出問題。於是tmux提出了類似vim的復制模式。因此,tmux下有兩套復制方法。
按下shift的同時,使用ctrl+shift+c、ctrl+shift+v可以用以前的方式進行復制粘貼。這種方式的好處就是可以復制到操作系統的粘貼板中。
下面重點介紹tmux在vim模式下的復制粘貼。
~/.tmux.conf
set-window-option -g mode-keys vi #可以設置為vi或emacs
set-window-option -g utf8 on #開啟窗口的UTF-8支持
tmux復制模式下可用的命令:
Function vi emacs
Back to indentation ^ M-m
Clear selection Escape C-g
Copy selection Enter M-w
Cursor down j Down
Cursor left h Left
Cursor right l Right
Cursor to bottom line L
Cursor to middle line M M-r
Cursor to top line H M-R
Cursor up k Up
Delete entire line d C-u
Delete to end of line D C-k
End of line $ C-e
Goto line : g
Half page down C-d M-Down
Half page up C-u M-Up
Next page C-f Page down
Next word w M-f
Paste buffer p C-y
Previous page C-b Page up
Previous word b M-b
Quit mode q Escape
Scroll down C-Down or J C-Down
Scroll up C-Up or K C-Up
Search again n n
Search backward ? C-r
Search forward / C-s
Start of line 0 C-a
Start selection Space C-Space
Transpose chars C-t
復制模式步驟:
1、C-b [ 進入復制模式
2、參考上表移動鼠標到要復制的區域,移動鼠標時可用vim的搜索功能"/","?"
3、安空格鍵開始選擇復制區域
4、選擇完成后安enter鍵退出
5、C-b ] 粘貼