In its default configuration, PuTTY sends cursor keys in normal mode, e.g., ^[OA
while screen sets the cursor keys to application mode, e.g., ^[[A
.
That is done by screen's sending the escape sequence to turn on the keypad (in termcap ks
, terminfo smkx
). That happens to turn on the application mode for both the numeric keypad and the cursor keys, because both are present in the ks/smkx
capability. screen uses this capability if it is present, when initializing the terminal. screen also follows up by sending the string in the termcap CS
capability if it is set, hinting that the original design was to use terminal descriptions where only the keypad was initialized by ks/smkx
.
You notice this difference because your key bindings expect the strings sent by the cursor keys in normal mode. If you modified the terminal description for screen to omit the part which changes the cursor keys, you could continue to use those bindings.
For instance, you could do this:
infocmp screen >foo
vi foo
and change the assignment
smkx=\E[?1h\E=,
to
smkx=\E=,
then
tic foo
to compile the modified description. If you do this as your (non-root) user, tic will put the compiled description in your ~/.terminfo
directory. There are drawbacks to this approach, and using tput
to obtain key-binding information is preferable. But it is simple.
Further reading:
With those, you first need to unmap them:
For example, for CTRL+J put the following line in the file '.vimrc':
let g:BASH_Ctrl_j = 'off'
Best Answer
Figure out exactly what escape sequence your terminal sends for Ctrl+arrow by typing Ctrl+V, Ctrl+arrow in insert mode: this will insert the leading
ESC
character (shown as^[
in vim) literally, followed by the rest of the escape sequence. Then tell vim about these escape sequences with something likeI seem to recall that Putty has a default setting for Application Cursor Keys mode that's inconvenient (I forget why), you might want to toggle this setting first.
Note that although escape sequences vary between terminals, conflicts (i.e. an escape sequence that corresponds to different keys in different terminals) are rare, so there's no particular need to try to apply the mappings only on a particular terminal type.