按下**前缀 [**进入文本复制模式。可以使用方向键在屏幕中移动光标。默认情况下,方向键是启用的。在配置文件中启用 Vim 键盘布局来切换窗口、调整窗格大小。Tmux 也支持 Vi 模式。要是想启用 Vi 模式,只需要把下面这一行添加到 .tmux.conf 中:
setw -g mode-keys vi
启用这条配置后,就可以使用 h、j、k、l 来移动光标了。
想要退出文本复制模式的话,按下回车键就可以了。一次移动一格效率低下,在 Vi 模式启用的情况下,可以辅助一些别的快捷键高效工作。
例如,可以使用 w 键逐词移动,使用 b 键逐词回退。使用 f 键加上任意字符跳转到当前行第一次出现该字符的位置,使用 F 键达到相反的效果。
vi emacs 功能
^ M-m 反缩进
Escape C-g 清除选定内容
Enter M-w 复制选定内容
j Down 光标下移
h Left 光标左移
l Right 光标右移
L 光标移到尾行
M M-r 光标移到中间行
H M-R 光标移到首行
k Up 光标上移
d C-u 删除整行
D C-k 删除到行末
$ C-e 移到行尾
: g 前往指定行
C-d M-Down 向下滚动半屏
C-u M-Up 向上滚动半屏
C-f Page down 下一页
w M-f 下一个词
p C-y 粘贴
C-b Page up 上一页
b M-b 上一个词
q Escape 退出
C-Down or J C-Down 向下翻
C-Up or K C-Up 向下翻
n n 继续搜索
? C-r 向前搜索
/ C-s 向后搜索
0 C-a 移到行首
Space C-Space 开始选中
C-t 字符调序
杂项:
d 退出 tmux(tmux 仍在后台运行)t 窗口中央显示一个数字时钟? 列出所有快捷键: 命令提示符
配置选项:
# 鼠标支持 - 设置为 on 来启用鼠标* setw -g mode-mouse off* set -g mouse-select-pane off* set -g mouse-resize-pane off* set -g mouse-select-window off# 设置默认终端模式为 256colorset -g default-terminal "screen-256color"# 启用活动警告setw -g monitor-activity onset -g visual-activity on# 居中窗口列表set -g status-justify centre# 最大化/恢复窗格unbind Up bind Up new-window -d -n tmp /; swap-pane -s tmp.1 /; select-window -t tmpunbind Downbind Down last-window /; swap-pane -s tmp.1 /; kill-window -t tmp
配置文件(~/.tmux.conf):
# 基础设置set -g default-terminal "screen-256color"set -g display-time 3000set -g escape-time 0set -g history-limit 65535set -g base-index 1set -g pane-base-index 1# 前缀绑定 (Ctrl+a)set -g prefix ^aunbind ^bbind a send-prefix# 分割窗口unbind '"'bind - splitw -vunbind %bind | splitw -h# 选中窗口bind-key k select-pane -Ubind-key j select-pane -Dbind-key h select-pane -Lbind-key l select-pane -R# copy-mode 将快捷键设置为 vi 模式setw -g mode-keys vi# 启用鼠标(Tmux v2.1)set -g mouse on# 更新配置文件bind r source-file ~/.tmux.conf /; display "已更新"#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<# Tmux Plugin Manager(Tmux v2.1)# Tmux Resurrectset -g @plugin 'tmux-plugins/tmux-resurrect'# List of pluginsset -g @plugin 'tmux-plugins/tpm'set -g @plugin 'tmux-plugins/tmux-sensible'# Other examples:# set -g @plugin 'github_username/plugin_name'# set -g @plugin 'git@github.com/user/plugin'# set -g @plugin 'git@bitbucket.com/user/plugin'# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)run '~/.tmux/plugins/tpm/tpm'#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>