Saturday, November 18, 2006

Arrow keys on the macbook pro

I used to have this exact problem when I used Linux on a Thinkpad several years ago. Try to use vim from the console, and the arrow keys simply don't work. There are a couple solutions to this problem, from what I understand, but I like this one b/c its simple and easy to apply on the fly whatever kind of terminal you find yourself in front of.

  1. Lookup the key you want to override - :help terminal-options
  2. Then type "set ~option~=~Control V~~press the key that doesn't work~"
  3. The key is now overriden. To make it permanent, copy the command into your .vimrc (use : to view a buffer of all ex commands for easy copy/pasting).

This might sound a little complicated. Its not. Here is an example. Say that the 'up' arrow key doesn't do anything when you are in vim. No problem.

  1. Type :help terminal-options --- Aha, I see a table and in that table it says that 't_ku' is the 'arrow up' key.
  2. Type :set t_ku=~Ctrl-V~~up~ (where everything between ~s are the control V and then pushing the up key).
  3. Tada, the up arrow key now works correctly.


Phil Test said...

what do you use arrow keys for in vim?

DeeSumm said...

Funny! Good question. Just ex mode stuff.

Todd Johnson said...

Thanks a ton!

:set t_ku=^[OA
:set t_kd=^[OB
:set t_kr=^[OC
:set t_kl=^[OD

in my ~/.vimrc lets me use the arrow keys in insert mode now!