Home | Photos | Family | Linux | Motorcycling | Work
NOTE: There are 9 links related to this category.

Numeric keypad in iTerm with vi

Well ... this frustrated the heck out of me and consumed most of my morning. Here's the issue:
I'm using iTerm with on Mac OS X (Panther). When I used vi, on either a remote or local machine, my numeric keypad was outputting q, r, s, along with some control characters. Because of the way it was acting, I assumed that it was outputting control characters of some kind. Turns out that the numeric keypad "1" was sending "[Oq" to vi. It took for ever to figure this out for a couple of reasons:

1. It seemed to only affect iTerm. GLTerm worked fine. ...this would seem indicate to me that it's an issue with iTerm.
2. At a command prompt, on either my local or a remote (linux) machine, the numeric keypad output exactly what it was supposed to ... numbers. I went so far as to put a sniffer on it to verif that it was actually sending this. ...this would seem to indicate to me an issue with vi.
3. I used telnet to access a local machine, and fired up Ethereal in X, went into vi and typed a bunch of stuff with the numeric keypad, iTerm was sending the commands. ... this would seem to indicate a problem with iTerm.

...see my troubleshooting problem? :)

Long story short, after much fruitless googling, I finally was able to find something that would work for me. I don't think it really fixes the problem, it seems like more of a bandaid, but none the less it works.

I modified my /etc/vimrc from:

if &term=="xterm"
     set t_Co=8
     set t_Sb=^[4%dm
     set t_Sf=^[3%dm
endif

Note: This was on a linux machine (FC1). This didn't exist on my mac.

To:

if &term=="xterm" || &term=="xterm-color"
     set t_Co=8
     set t_Sb=^[4%dm
     set t_Sf=^[3%dm
     :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 -
endif
This fixed the problem both on Linux, and on my Mac. I'm not sure if it's the correct way to fix the issue, but it seemed to work.

Also, if you miss syntax highliting, you may want to add this:

:syntax enable

Update: In OS X Tiger, this file in /usr/share/vim/vimrc
Hope this helps someone!

Created by swannie on 2005-04-11 13:26:55, modified by swannie on 2005-06-21 19:19:23.
Modify Page

Home > Linux > Mac OS X > Numeric keypad in iTerm with vi

Hosting for this website generously provided by Narnia Pet Behavior and Training, Inc. Page dynamically created using PHP, page last modified on November 05, 2003 11:00:16.
All images and texts contained herin are © Copyright 1995-2012 swannie.net, and Brian R. Swan unless noted otherwise. All rights reserved.