Vim Tips Wiki
(Move categories to tip template)
(Adjust previous/next navigation)
Line 3: Line 3:
 
|id=503
 
|id=503
 
|previous=502
 
|previous=502
|next=505
+
|next=506
 
|created=July 3, 2003
 
|created=July 3, 2003
 
|complexity=advanced
 
|complexity=advanced

Revision as of 03:48, 27 April 2008

Tip 503 Printable Monobook Previous Next

created July 3, 2003 · complexity advanced · author Michael Metzger · version 5.7


Purpose: Add support for {rhs} of keyboard numeric keypad while in vim insert mode and using PuTTY as a SSH terminal connection.

What to do: Add these mappings to your vimrc or gvimrc. PuTTY's default terminal type is xterm. Check your settings or just echo $TERM at the command prompt on most unix systems to verify xterm type.

Code to add to vimrc:

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

Comments

You might also want to include the mappings for the normal mode as well. For example, going to a specific line

  1. +shift G will not work unless you put these additional mappings in _vimrc.
:map ^[Oq 1
:map ^[Or 2
:map ^[Os 3
:map ^[Ot 4
:map ^[Ou 5
:map ^[Ov 6
:map ^[Ow 7
:map ^[Ox 8
:map ^[Oy 9
:map ^[Op 0

Sadly, this does not work for me (vim v6.1.265, TERM=xterm). Using these mappings, vim resorts to the regular behaviour of inserting a new character on the previous line.


Additionally, those of you that are having issues with the keypad can remap it using the following command sequence in your vimrc file:

:imap ^[0A <Up>
:imap ^[0A <Down>
:imap ^[0A <Left>
:imap ^[0A <Right>

These settings also seemed to correct the quirk of the mode text (or whatever it is properly called: --INSERT--) not showing up at the bottom of the screen when in insert mode.


Maybe a simpler way to do this in PuTTY's settings: Set "Disable application keypad mode" under Terminal-->Features.


I'm using :

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