When I establish a SSH
connection to my machine using PuTTY
, I find that the Control + Arrow keys
behave unexpectedly when working with vim
or nvim
in the bash terminal.
For instance, in vim
, escaping Ctrl + Left Arrow
and just the Left Arrow
both output ^[OD
.
While in the case of nvim
, they both output <left>
.
However, when I open vim
or nvim
inside tmux
, the keys function as expected. In this case, the escaped Control + Left Arrow
generates ^[[1;5D
, while the Left Arrow
outputs ^[OD
.
In nvim
, the corresponding outputs are <C-Left>
and <Left>
respectively.
I found a little workaround by ticking the box next to Terminal > Features > Disable application cursor keys mode
. This enables proper functionality for the Control + Arrow keys
in both vim
and nvim
, even outside of tmux
.
Escaping Control + Left Arrow
now results in ^[[1;5D
, and the Left Arrow
yields ^[OD
. (Likewise with nvim
returning <C-left>
and <left
respectively)
However, this change introduces a new issue. The arrow keys stop functioning when navigating through commands such as top
, htop
, or man
(when inside bash
). They still continue to work within tmux
.
So, to address this, I attempted to add the following to ~/.inputrc
"eOD": backward-word
"eOC": forward-word
"eOA": previous-history
"eOB": next-history
Regrettably, this doesn’t rectify the problem;
So, I’m hoping to find a solution that allows Ctrl + Arrow keys
to work within a standard bash
environment, without compromising the scrolling functionality. Or, the other way around; Either goes…
Tmux config:
$ echo $TERM
screen
$ cat /usr/share/docs/tmux/example_tmux.conf
# Enable RGB colour if running in xterm(1)
set -ag terminal-overrides ",screen-256color:Tc"
# Change the default $TERM to tmux-256color
set -g default-terminal "screen-256color"
# Turn the mouse on, but without copy mode dragging
set -g mouse on
unbind -n MouseDrag1Pane
unbind -Tcopy-mode MouseDrag1Pane