The Home and End keys on Mac OS X work quite a bit different then one would expect coming from other operating systems. Instead of the familiar beginning of line and end of line behaviour Apple decided that it should put the courser at the beginning or the end of the document. I find this highly annoying to say the least. Fortunately it is easy enough to fix this.

If the ~/Library/KeyBindings directory doesn’t exist then create it:

    mkdir ~/Library/KeyBindings

Then create the ~/Library/KeyBindings/DefaultKeyBinding.dict file with the following content:

{
    /* home */
    "UF729"  = "moveToBeginningOfLine:";
    "$UF729" = "moveToBeginningOfLineAndModifySelection:";

    /* end */
    "UF72B"  = "moveToEndOfLine:";
    "$UF72B" = "moveToEndOfLineAndModifySelection:";

    /* page up/down */
    "UF72C"  = "pageUp:";
    "UF72D"  = "pageDown:";
}

Enjoy!