The problem is the value of the TERM environment variable does not match the configured terminal characteristics - specifically the "Home and End keys" and "Function keys and keypad" settings.
These can be hard to get right.
What is expected by the Debian server.
Type infocmp -I
to see what your computer is expecting.
$ infocmp -I
# Reconstructed via infocmp from file: /usr/share/terminfo/a/ansi
ansi|ansi/pc-term compatible with color,
…
rmul=\E[m, il1=\E[L, kbs=^H, kcbt=\E[Z, kcud1=\E[B,
khome=\E[H, kich1=\E[L, kcub1=\E[D, kcuf1=\E[C, kcuu1=\E[A,
…
khome=\E[H
means that the server expects to receive three characters ESC [ H
when you press Home.
You can look at what is expected for other values of TERM
$ infocmp -I xterm
# Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm
xterm|X11 terminal emulator,
…
is2=\E[!p\E[?3;4l\E[4l\E>, il1=\E[L, ka1=\EOw, ka3=\EOu,
kb2=\EOy, kbs=\177, kbeg=\EOE, kc1=\EOq, kc3=\EOs,
kdch1=\E[3~, kcud1=\EOB, kend=\E[4~, kent=\EOM, kf1=\EOP,
kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~,
kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~,
kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR,
kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
kf9=\E[20~, khome=\E[1~, kich1=\E[2~, kcub1=\EOD,
kmous=\E[M, knp=\E[6~, kpp=\E[5~, kcuf1=\EOC, kcuu1=\EOA,
…
Here you can see that, if TERM
were set to xterm
, this server would expect to receive ESC [ 1 ~
when Home is pressed (khome
)
If the above is too cryptic, try infocmp -L
You can also do things like tput khome | hexdump -C
if you know the terminfo capability names for the keys you are interested in.
$ tput khome | hexdump -C
00000000 1b 5b 48 |.[H|
or, arguably more legibly
$ tput khome | hexdump -e '12/1 "%3_u" "\n"'
esc [ H
or to see what another TERM setting might mean
$ TERM=xterm tput khome | hexdump -e '12/1 "%3_u" "\n"'
esc [ 1 ~
if the output is empty the server thinks that terminal type (TERM) doesn't have that key.
What is actually sent by Putty.
To see what Home actually sends, run vi
, press i (for insert mode) press Ctrl+V then press Home and press Esc to exit insert mode.
Solution
Adjust Putty config (or TERM) until what is sent matches what the other end expected.
E.g.
Do as specified in https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/terminfo.html then in Putty, Configuration, Connection, Data, terminal-type string = PuTTY and save that. Maybe.
I had the same problem, i solved with this solution: http://superuser.com/a/104001
– jncruces – 2015-10-28T10:16:10.370this did it for me: http://vim.wikia.com/wiki/PuTTY_numeric_keypad_mappings
– JonnyRaa – 2017-09-27T15:14:08.237