OK, so for anyone who uses OSX , and admins Linux machines, this can be a real headache.
For some reason the default settings for your Home and End keys that come with Terminal.App for OSX don't do what you expect - theyre Actually Swapped with Shift Home , and Shift End, but thats not all, as the escape sequence for Shift Home for example, is set to "\033[H". This seems to work fine on OSX, but unfortunately you try logging into a Linux Box with that, and on the command line it works, but try loading vi and using the Home key - and you get nothing. The same applies to the End key as well, OSX has it defined it as \033[F, however vim remotely does not like this either. (I Believe this applies to all termcap applications, allthough i can't be sure).
The Solution for both of these is to change the definitions of these keys, so theyre mapped as you expect, and get it to send the right escape sequence at the same time, I don't believe mapping OSX's [H and [F mappings in vim on the remote host, because well , when you admin 10 machines or more, it well doesn't make sense to put it mildly, so this is the only viable solution.
Before we can do this however we need to create a file, open up a Terminal window, and type the following: sudo nano /private/etc/inputrc, then enter your password (you need to be an admin user for this). Now paste in the following code:
CODE:
"\e[1~": beginning-of-line
"\e[4~": end-of-line
followed by Pressing CTRL and X, then typing y, and hitting enter.
(Note: If you don't want to do this change system wide, change the command to nano ~/.inputrc, and add export INPUTRC="~/.inputrc" to your .profile)
Now we've done that we shall deal with Home/End, hit CMD I in terminal, and click Settings, followed by double clicking whichever entry is selected. In the window that appears click on the "Keyboard" tab, and find the entry for Home, click on it , and click edit. Change the action to "send string to shell:", now in the box below that, hit the following keys: "
[1~" ( as in the escape key, and without the quotes) and click OK. Now do the same for End, except you type "[4~" (without the quotes).
Next find Shift Home, and edit that to change its action to: "scroll to start of buffer" then do the same for Shift End, editing that and changing its action to: "scroll to end of buffer".
Right, now Restart Terminal.
Try your home and end keys, they should work, both on command line and inside vim. Both locally and remotely. If they don't try hitting CTRL V .. it should reply with ^[[1~ .. and CTRL V should reply with ^[[4~. If it doesn't, you've gone wrong somewhere!.
Comments welcome.
Keith