如何使用Control+箭头切换屏幕中的vim个标签?

How to use Control+arrow to switch vim tabs in screen?

我已经配置 vim 通过在 .vimrc:

中添加以下行来使用 control+箭头切换选项卡
map <F7> :tabp<cr>
map <F8> :tabn<cr>
map <C-up> :tabr<cr>
map <C-down> :tabl<cr>
map <C-left> :tabp<cr>
map <C-right> :tabn<cr>

screen 中,<F7><F8> 有效,但 control+arrows 无效...

知道为什么吗?以及如何解决?谢谢

我不确定它是否有效,但您可以尝试将此代码包含在您的 vimrc:

if &term =~ '^screen'
    sil! exe "set <xUp>=\e[1;*A"
    sil! exe "set <xDown>=\e[1;*B"
    sil! exe "set <xRight>=\e[1;*C"
    sil! exe "set <xLeft>=\e[1;*D"
endif

我从here复制过来的。

如果你使用 tmux,你可能还需要在你的 tmux 配置文件中启用选项 xterm-keys (~/.tmux.conf):

set-option -gw xterm-keys on

man tmux中有描述:

 xterm-keys [on | off]
         If this option is set, tmux will generate xterm(1) -style function key sequences; these have a
         number included to indicate modifiers such as Shift, Alt or Ctrl.  The default is off.

我不知道 screen 的等价物是什么。


也有可能某些东西(window 管理器、终端多路复用器、终端仿真器)在 Vim 之前拦截了 <C-left>

要排除这种可能性,您可以尝试在插入模式下键入 C-v C-left,按字面意义将 <C-left> 插入 Vim 缓冲区,然后查看它显示的内容。在我的机器上,它显示 ^[[1;5D,所以我知道没有什么拦截 <C-left>

如果什么都没有显示,那么您将不得不找到正在拦截的软件<C-left>并删除其配置中的键绑定。