Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Most of my computing time is spent in Linux (with occasional time in Windows). On these platforms the Home and End keys universally jump to the beginning or end of the current line.

I am gradually getting used to using the one Apple computer in my life, but it is still frustrating than these keys seem to be bound to the beginning and end of the document and there doesn't seem to be any key at all for the line based actions.

My question:

  1. Are there existing keybindings I'm missing for beginning and end of line? (I mostly use a Terminal, Chrome and LibreOffice)
  2. Is there a way to rebind the functions of these keys to the functions I am familiar with? I am willing to give up the document based versions which seem of little use to me.

Also two caveats:

  1. I am not the only user on the system. It would be nice if my user settings didn't break other peoples experience. If this isn't possible, I think I probably have the strongest preference!
  2. I do use multiple languages and switch between keyboard layouts, so any solutions would be expected to work even when toggling between multiple keyboard layouts.
share|improve this question
Note that while I ended up finding a solution and answering my own question, I'm open to easier or more versatile solutions. Also the process of discovering this is not clear. For example where do you find key codes and action names if I wanted to remap more keys? Feel free to add answers if you have relevant knowledge! – Caleb Jun 18 '11 at 9:08
up vote 111 down vote accepted

The default shortcuts for moving to beginning or end of (wrapped) lines are ⌘← and ⌘→. ⌥↑ and ⌥↓ or ⌃A and ⌃E move to the beginning or end of unwrapped lines (or paragraphs).

You could remap home and end by creating ~/Library/KeyBindings/ and saving a property list like this as DefaultKeyBinding.dict:

    "\UF729"  = moveToBeginningOfParagraph:; // home
    "\UF72B"  = moveToEndOfParagraph:; // end
    "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
    "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end

Applying changes requires reopening applications. DefaultKeyBinding.dict is ignored by some old versions of Xcode (works with latest version 6.3.1), Terminal, and many cross-platform applications.

See Cocoa Text System and my website for more information about the customizable keybindings.

Terminal's keybindings can be customized in Preferences > Settings > Keyboard. \033OH moves to the beginning of a line and \033OF to the end of a line.

In Eclipse, key bindings should be modified in Preferences > General > Keys. You need to modify default bindings for commands Line Start and Line End (replace ⌘← by ↖ and ⌘→ by ↘).

share|improve this answer
Thanks @Lri, the extra links and existing bindings were exactly what I was looking for. Also, LibreOffice seems to respond just fine to the remapped keys. – Caleb Jun 18 '11 at 9:12
+1 for Terminal keybindings – rymo Dec 13 '13 at 21:56
I have tried creating a DefaultKeyBindings as above (at time of writing) on the latest release (El Capitan) and it seems the Chrome is no longer respecting the DefaultKeyBindings.dict file. Has anyone had any luck using the above native methods? If so, did you have to use a workaround? – GrayedFox Nov 11 '15 at 19:41
For terminal ctrl+A and ctrl+E are the commands to use! That was termendously helpful for me. (I knew cmd+right/left previously but..) – csga5000 Nov 20 '15 at 1:38

I'm currently on Lion 10.7.4, and for some strange reason editing the ~/Library/KeyBindings/DefaultKeyBinding.dict didn't work for me.

I have found that the KeyRemap4MacBook System Preferences addon works really well, and you can also re-map a variety of keys with it, without having to edit any text files. E.g. changing the page up / page down keys so the cursor also follows on page up / down.

Just download the addon, and in the System Preferences panel, browse to the For PC Users section, and check Use PC Style Home /End.

Note, I picked (Change Home to Command+Left) instead of (Change Home to Control+A), as if I picked the first, and if the line was wrapped, home would take me to the beginning of the wrapped line, several lines above, instead of taking me to the beginning of the current line.


share|improve this answer
This is the only thing that really works. – Louis Mar 13 '13 at 21:53
Indeed it works immediately, and it's way easier. Thanks! – Matthieu Napoli Oct 8 '13 at 19:10
Karabiner is great and also open source – Jedidja Feb 4 '15 at 17:14
With 10.10.5, the other suggestions seem to not work, but Karabiner (the new name for KeyRemap4MacBook -- works on all the Mac products) works well, and doesn't need a restart for the changes to take effect. Immensely helpful for this Mac noob; hopefully others can benefit as well. – Ralph J Nov 10 '15 at 15:36
Karabiner only maps connected devices, so this won't work if you're using VNC, Splashtop, etc. However, the KeyBindings answers do work for Splashtop (which I'm currently using) and I'd assume they'd also work for VNC. – Bezewy Dec 3 '15 at 22:43

Thanks to this article, I figured out how to re-bind the Home and End keys to line based actions on a per-user basis that works across keyboard layouts.

You need to create a dictionary file with the keycodes and new commands to map to, but first make sure the folder where this will be placed exists by opening a Terminal and running:

$ mkdir -p ~/Library/KeyBindings

Then create or edit the file at ~/Library/KeyBindings/DefaultKeyBinding.dict. If it didn't exist before, add the whole section below. If it does exist, just add the four new rows inside the block.

    "\UF729"  = "moveToBeginningOfLine:";
    "\UF72B"  = "moveToEndOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";

In order to activate the settings you will need to logout of your user and login again.

Note that this covers both the normal action of moving the cursor and the Shift+Home/End combination to select durring cursor movement.

share|improve this answer
THANK YOU! Apple's default home/end usage is an absolutely loony-tunes/maddening standards violation for those of us that operate on a wide variety of platforms! You may have just saved my MacBook from taking a vertical trip off the roof of our office building. :-) – Brian Knoblauch Oct 9 '12 at 15:41
@BrianKnoblauch: The only saving grace is that this fix is user specific, so you can fix your login to be a sane environment without messing up the poor ignorant Mac only junkies whose computer you are using. – Caleb Oct 9 '12 at 15:51
THANKS!! I am using Yosemite and this works perfectly for editing google docs. I had previously modified the bindings in some system location, but that got wiped when i upgraded. – John Henckel May 14 at 13:45

I'm using the awesome KeyRemap4MacBook with the custom settings below.

It fixes Home/End in most applications and doesn't screw up iTerm2.


<?xml version="1.0"?>
<!-- ~/Library/Application Support/KeyRemap4MacBook/private.xml -->
<!-- Custom keyboard mappings for MBP using -->
        <name>Lari's PC Style Home/End</name>
        <appendix>(Change Home to Command+Left)</appendix>
        <appendix>(Change End to Command+Right)</appendix>
        <appendix>{{ PC_STYLE_BINDINGS_IGNORE_APPS_DESCRIPTION }}</appendix>
            <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME, ModifierFlag::SHIFT_L</autogen>
            <autogen>__KeyToKey__ FROMKEYCODE_END,  KeyCode::END,  ModifierFlag::SHIFT_L</autogen>
            <autogen>__KeyToKey__ FROMKEYCODE_HOME, KeyCode::HOME</autogen>
            <autogen>__KeyToKey__ FROMKEYCODE_END,  KeyCode::END</autogen>
            <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>
            <not>{{ PC_STYLE_BINDINGS_IGNORE_APPS }}</not>
            <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>
share|improve this answer
Thanks this was very useful! – Siddhartha Apr 29 '15 at 18:21

Imho the best tool to make keyboard changes is indeed Karabiner (old name KeyRemap4MacBook). Open source ( but also available as application ( I have been searching quite a long time and I have never find anything better.

share|improve this answer

You can also remap keyboard keys, as well as customize your mouse and trackpad in all kinds of cool ways, with the free BetterTouchTool, available at An excellent solution for customizing the workings of your input devices!

share|improve this answer
Could you expand your answer with instructions on how to use the specified software to solve the original problem? – grgarside Jun 11 '15 at 18:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.