How to change Home / End behaviour on Yosemite

I want to change the Home and End keys to work like Windows/Linux.

CHANGE:

Home to Command-Left Arrow. // Beginning of the line

End to Cmd-Right Arrow. // End of the line

I tried using Karabiner app known as KeyRemap4MacBook. But it doesn't work on Yosemite while I write code on editors like Sublime Text, PhpStorm, WebStorm, etc.

I also did create a DefaultKeyBindings.dict file (with proper settings) inside ~/Library/KeyBindings/ and OSX/Library/KeyBindings/.

So, is there a way to remap the Home and End keys for glabally on my mac. I could use Terminal command too. I don't want an app for that.


You might have to change the custom settings in the Terminal app. But it's quite straight forward. See here: http://fdiv.net/2007/05/12/keybindings-in-macosx-terminal-app

I also changed it for my Sublime Text 2:

   { "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
   { "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },

It is possible to achieve this behavior using Karabiner (I know you tried already, but please read). I use it extensively on Yosemite (10.10.2)

Optional (can't remember if is 100% necessary), but follow just in case:

  • Add Karabiner_AXNotifier.app on System Preferences > Security & Privacy > Privacy (tab or horizontal menu on top) > Accessibility (left column)

Then:

  1. Open Karabiner preferences and go to the ‘Misc & Uninstall’ tab.
  2. Click the ‘Open private.xml’ button (under ‘Custom Settings’)
  3. Add this content to private.xml (create the file if doesn't exist):

    <?xml version="1.0"?>
    <root>
        <item>
          <name>Fix Home/End</name>
          <appendix>(Home/End move to beg/end of line, Ctl/Cmd+Home/End move to beg/end of page)</appendix>
          <identifier>remap.app_firefox_fix_home_end</identifier>
          <only>FIREFOX, THUNDERBIRD</only>
          <autogen>__KeyToKey__ FROMKEYCODE_HOME, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND, KeyCode::CURSOR_UP,   ModifierFlag::COMMAND_L</autogen>
          <autogen>__KeyToKey__ FROMKEYCODE_HOME, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL, KeyCode::CURSOR_UP,   ModifierFlag::COMMAND_L</autogen>
          <autogen>__KeyToKey__ FROMKEYCODE_END,  MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND, KeyCode::CURSOR_DOWN, ModifierFlag::COMMAND_L</autogen>
          <autogen>__KeyToKey__ FROMKEYCODE_END,  MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_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>
        </item>
    </root>
    
  4. Return to the ‘Change Key’ tab.

  5. Click the ‘Reload XML’ button.
  6. Search for ‘System-wide’ in the search box and check the ‘Fix Home/End System-wide’ (I named it this way to make it easier for you to activate)
  7. Try the Home/End keys.