Apple - Possible to move the cursor word-by-word with Cmd+left/right instead of Alt+left/right?

One option would be to create ~/Library/KeyBindings/ and save this as DefaultKeyBinding.dict:

{
    "@\UF702" = moveWordBackward:;
    "@\UF703" = moveWordForward:;
    "~\UF702" = moveToBeginningOfLine:;
    "~\UF703" = moveToEndOfLine:;
    "~$\UF702" = moveToBeginningOfLineAndModifySelection:;
    "~$\UF703" = moveToEndOfLineAndModifySelection:;
}

You can't change ⇧⌘← or ⇧⌘→ though. And it doesn't work in some text views or Xcode or Firefox.

Using KeyRemap4MacBook, you could add this to private.xml:

<autogen>--KeyToKey-- KeyCode::CURSOR_LEFT, VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_LEFT, VK_COMMAND</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_RIGHT, VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_RIGHT, VK_COMMAND</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_LEFT, VK_SHIFT | VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_LEFT, VK_SHIFT | VK_COMMAND</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_RIGHT, VK_SHIFT | VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_RIGHT, VK_SHIFT | VK_COMMAND</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_LEFT, VK_COMMAND | ModifierFlag::NONE, KeyCode::CURSOR_LEFT, VK_OPTION</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_RIGHT, VK_COMMAND | ModifierFlag::NONE, KeyCode::CURSOR_RIGHT, VK_OPTION</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_LEFT, VK_COMMAND | VK_SHIFT | ModifierFlag::NONE, KeyCode::CURSOR_LEFT, VK_OPTION | VK_SHIFT</autogen>
<autogen>--KeyToKey-- KeyCode::CURSOR_RIGHT, VK_COMMAND | VK_SHIFT | ModifierFlag::NONE, KeyCode::CURSOR_RIGHT, VK_OPTION | VK_SHIFT</autogen>

It would make going back with ⌘← and changing tabs with ⇧⌘← stop working though.

See the source for the key code constants and predefined settings.


Yes. Using Keyboard Maestro, I just created two new macros.

The first has a "hot key trigger" of < command >< left arrow > and does a "type a keystroke" of < option >< left arrow >

The second is the reverse, a "hot key trigger" of < option >< left arrow > and does a "type a keystroke" of < command >< left arrow >. And it does work.

You could then add 2 more macros for the right direction.

The way I wrote them as a quick test they are system wide but they can be limited to specific sets of applications.

While Keyboard Maestro is not free, it does have time limited demo.

Tags:

Macos

Keyboard

Ui