Another way to remap home and end is to save a property list like this as ~/Library/KeyBindings/DefaultKeyBinding.dict:
{ "\UF729" = moveToBeginningOfLine:; "\UF72B" = moveToEndOfLine:; "$\UF729" = moveToBeginningOfLineAndModifySelection:; "$\UF72B" = moveToEndOfLineAndModifySelection:; }
It doesn't work in as many places as KeyRemap4MacBook, but there are also less false positives.
If you use one of the predefined settings in KeyRemap4MacBook, you can customize it by copying it from https://raw.github.com/tekezo/KeyRemap4MacBook/master/Tests/lib/string/data/checkbox.xml to private.xml:
<?xml version="1.0"?> <root> <item> <name>Use PC Style Home/End (except in Virtual Machine,RDC)</name> <appendix>(Change Home to Command+Left)</appendix> <appendix>(Change End to Command+Right)</appendix> <appendix>(+ Change Home to Control+A in Emacs,Terminal,X11,Eclipse)</appendix> <appendix>(+ Change End to Control+E in Emacs,Terminal,X11,Eclipse)</appendix> <identifier>remap.pclikehomeend</identifier> <block> <only>DREAMWEAVER</only> <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME, ModifierFlag::SHIFT_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, KeyCode::END, ModifierFlag::SHIFT_L</autogen> </block> <block> <only>BLUEFISH,WORD,EXCEL,POWERPOINT</only> <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, KeyCode::END</autogen> </block> <block> <not>EMACS, TERMINAL, VIRTUALMACHINE, REMOTEDESKTOPCONNECTION, X11, ECLIPSE</not> <autogen>__KeyToKey__ FROMKEYCODE_HOME, VK_COMMAND, KeyCode::CURSOR_UP, ModifierFlag::COMMAND_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_HOME, VK_CONTROL, KeyCode::CURSOR_UP, ModifierFlag::COMMAND_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, VK_COMMAND, KeyCode::CURSOR_DOWN, ModifierFlag::COMMAND_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, VK_CONTROL, KeyCode::CURSOR_DOWN, ModifierFlag::COMMAND_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen> </block> <block> <only>EMACS, TERMINAL, X11, ECLIPSE</only> <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::A, ModifierFlag::CONTROL_L</autogen> <autogen>__KeyToKey__ FROMKEYCODE_END, KeyCode::E, ModifierFlag::CONTROL_L</autogen> </block> </item> </root>
You can use an appdef element to specify a new application:
<appdef> <appname>TEXTMATE</appname> <equal>com.macromates.TextMate.preview</equal> <equal>com.macromates.TextMate</equal> </appdef>