Wherein I occasionally rant on various topics including, but not limited to, PHP, Music, and whatever other Topics I find interesting at the moment, including my brain tumor surgery of August 2010.

Thursday, April 17, 2008

Solaris vi input mode arrow keys fix

This blog post is not for you to read.

It's for me.

You see, every once in a awhile, I work for a client/employer who uses Solaris, OpenSolaris, Unix, or some other traditional Unix-like OS.

They have their reasons, and they are good ones, and I'm fine with that.

Alas, I then usually waste about an hour of their time (and they pay me for it) to Google for the hack that makes vi (my editor of choice) actually usable from a terminal program (putty, usually).

To wit, the arrow keys in vi do not work in input mode under these OSes.

This blog post is a reminder for ME to know what the heck to do next time this happens.

So here is what I do:
Open up ~/.exrc and type these things:
set t_ku=[control-v][up-arrow]
set t_kd=[control-v][down-arrow]
set t_kr=[control-v][right-arrow]
set t_kl=[control-v][left-arrow]

Then make a symlink from .exrc to .vimrc
ln -s ~/.exrc ~/.vimrc

Finally, alias vi to vim, since this only works for vim:
alias vi=vim

Bonus Tip:
To get vi/vim to use more than ONE LINE when you start up, use:
TERM=putty screen

I believe "screen" is magical pixie dust that gives you a whole screen of line instead of one line, and the TERM stuff obviously tells screen that you need that screen to go to putty.

If "man screen" had been installed, perhaps I would have a better understanding of the magical pixie dust, but so it goes.