Vim, GNU Screen and arrow keys
Here’s a typcial scenario: I use Putty SSH into my University’s unix system, bring up screen and then proceed to do whatever work I have to do. Often this involves using Vim to write code or edit documents. Over the summer the CS department upgraded a bunch of their software - including upgrading Vim to Vim 7. Starting classes again I went to do my usual routine and found that the Arrow Keys in Vim under Screen would insert characters instead of moving the cursor. A solution was harder to find than I thought it should, so I’m posting it here:
Problem: Log into your unix/linux/solaris/whatever account and bring up screen. Launch Vim and in insert mode use the arrow keys to move your cursor. Up arrow inserts 0A or A, Down arrow inserts B, etc.
Solution: The best solution I found was this one which instructs you to use:
:set term=builtin_ansi
which I dropped into my .vimrc file. There are more solutions involving remapping keys, setting macros and tons of other over-the-top kind of stuff. Why its only problem in Putty using Screen (I’ve tested some other permutations) is beyond me.
While on the topic of Vim, if you’re using Windows you might want to check out intellisense for Vim, two of my favorite things.
**EDIT**
Ok, that doesn’t really solve the problem AND it disables syntax coloring. The problem, I’ve discovered, is that Vim is reading it’s terminal setting from Screen and using ’screen’ as it’s terminal type. Instead you’ll want to set it to xterm. I recommend adding:
set term=xterm
to your .vimrc
