Vim Tips Wiki
Advertisement
Tip 503 Printable Monobook Previous Next

created 2003 · complexity advanced · version 6.0


This tip contains information on using Vim over PuTTY.

PuTTY is a terminal emulator for Windows. It is commonly used as an SSH client to connect to a Unix-based server using the secure shell protocol. Console Vim (not gvim) can be run on the server, using PuTTY as the terminal.

PuTTY acts as an xterm. Check your settings or just echo $TERM at the command prompt on most Unix systems to verify the xterm type.

Using the numeric keypad

Why do letters show up when I try to enter numbers from the keypad? Why doesn't the numpad work as expected? Why does the NumLock key bring up help.txt?

These confusing things happen when PuTTY is in "application keypad mode".

PuTTY can be configured so that keys on the numeric keypad (including NumLock) will send an escape sequence ("application keypad mode"), or will behave as a standard number pad (when NumLock is on, send the characters [0-9/*-+.]; otherwise, send the codes for the cursor movement keys).

For use in Vim, you want to disable application keypad mode:

  • Run PuTTY Configuration.
  • In the left pane, select Terminal, Features.
  • Put a check mark next to "Disable application keypad mode".
  • In the left pane, select Session.
  • Save the settings.

Now the NumLock key and the numbers on the numpad should work in Vim, as expected.

See also

Comments

May rename this tip so any information relevant to using PuTTY can be placed here.

The original tip was a confused suggestion to define certain mappings so that Vim recognizes the escape sequences generated when keys on the numeric keypad are pressed, if the keypad is set to "application keypad mode".

For example, in application keypad mode, pressing the 1 key on the numeric keypad causes PuTTY to send the escape sequence <Esc>Oq (three byes). Pressing the NumLock key similarly generates an escape sequence.

It is possible to have Vim interpret the escape sequences using the following mappings (but this is not necessary – see tip):

:inoremap <Esc>Oq 1
:inoremap <Esc>Or 2
:inoremap <Esc>Os 3
:inoremap <Esc>Ot 4
:inoremap <Esc>Ou 5
:inoremap <Esc>Ov 6
:inoremap <Esc>Ow 7
:inoremap <Esc>Ox 8
:inoremap <Esc>Oy 9
:inoremap <Esc>Op 0
:inoremap <Esc>On .
:inoremap <Esc>OQ /
:inoremap <Esc>OR *
:inoremap <Esc>Ol +
:inoremap <Esc>OS -

Advertisement