TMUX 使用 HJKL 导航窗格 [英] TMUX using HJKL to navigate panes

查看:79
本文介绍了TMUX 使用 HJKL 导航窗格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在窗格之间导航时,标准 TMUX 设置为使用 ctrl-b + [上、下、左、右].

Standard TMUX is set to use ctrl-b + [up, down, left, right] when navigating between panes.

我想这样做,以便我可以使用 ctrl-b(或我选择的前缀)+ [h,j,k,l].

I would like to make it so that I can use ctrl-b (or the prefix of my choice) + [h,j,k,l].

我以为我在 ~/.tmux.conf 设置中使用以下 vi 键完成了此操作:

I thought I had done this with the following vi key in my ~/.tmux.conf settings:

set -g status-keys vi
setw -g mode-keys vi

然而这似乎并没有改变任何东西(至少不是我想要的).我怎样才能让它发挥作用.是的,我的 .tmux.conf 工作正常.如果需要,我可以提供更多信息.

Yet this didn't seem to change anything (at least not what I was looking for). How can I get this to work. And yes my .tmux.conf is working properly. I can provide more info if needed.

更新:

这是我尝试让它工作后的完整 .tmux.conf:

Here is my full .tmux.conf after trying to get it to work:

set -g status-keys vi
setw -g mode-keys vi

set -g prefix C-a
unbind C-b
bind C-a send-prefix


# smart pane switching with awareness of vim splits
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

或者,我尝试使用这个带有 vim-tmux-navigator Vim 插件:

Alternatively, I have tried using this w/ vim-tmux-navigator Vim plugin:

# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"

来源

这也不起作用.我有点难住了.

Which also doesn't work either. I am a bit stumped.

推荐答案

您可以这样做:

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

请注意,mode-keys 是指在缓冲区内使用类似 vi 的导航,而 status-keys 是指在状态栏中使用类似 vi 的编辑,但两者都不是指的是在窗格之间切换.

Note that mode-keys refers to using vi-like navigation within a buffer and status-keys refers to using vi-like editing within the status bar, but neither refers to switching between panes.

这篇关于TMUX 使用 HJKL 导航窗格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆