export TERM=linux
Ever since my Macbook died and was fixed again Vim hasn’t worked properly in iTerm.
I’m a big fan of SSH and Screen. SSH to connect to a remote server, and Screen is like a workspace organiser for your SSH session.
First of all the backspace key worked in Vim even when not in insert mode, but worst of all, the cursor keys refused to work and only succeeded in ringing bells in the terminal. Previous attempts at fixing the problem failed but I must have searched for the right terms this time. This review of Mac OS X led me part of the way. Sébastien recommended setting the TERM to “dtterm” but Screen didn’t recognise that. Setting it to “linux” fixes my SSH sessions, and also fixes Vim locally as well!
I added the snippet of code above to my ~/.bash_profile to make the change permanent and everything is back to normal now! I have a vague memory of fixing this before but I wish now I had blogged it then!