再也不用担心无法一边打开vim一边运行终端命令了

推荐~/.vimrc和~/.tmux.conf配置, 以实现vim和tmux窗格的平滑切换

  • vimrc添加并安装
Plugin 'christoomey/vim-tmux-navigator'
  • /.tmux.conf 添加:
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h"  "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j"  "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k"  "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l"  "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l

窗格却换:

<ctrl-h> => Left
<ctrl-j> => Down
<ctrl-k> => Up
<ctrl-l> => Right
<ctrl-\> => Previous split

知乎中截的图:

我自己的图:

vim+tmux更多配置 更多配置https://github.com/christoomey/vim-tmux-navigator

(Author)
No description.Please update your profile.

View all post by admin

Leave Comments

我们立足于美利坚合众国,对全球华人服务,受北美法律保护