Windows – Make Mac OS X “Option-Arrow” work like Windows “Ctrl-Arrow”

keyboardswitchingwindows

I rely on the "Ctrl" command on Windows to navigate my way through text documents.

This useful key-combo will quickly bring me to the beginning of the next word. For example, the following sequence illustrates what would happen to the cursor location after successive presses of Ctrl (the "^" will represent the cursor):

^The quick brown fox jumped over the lazy dog
The ^quick brown fox jumped over the lazy dog
The quick ^brown fox jumped over the lazy dog
The quick brown ^fox jumped over the lazy dog
The quick brown fox ^jumped over the lazy dog
...

And, if I start pressing the instead, it will move the cursor to the exact same spots in the document, just going the other direction (which is ideal because the position of the cursor is predictable, which leads to me being faster at making my edits):

The quick brown fox ^jumped over the lazy dog
The quick brown ^fox jumped over the lazy dog
The quick ^brown fox jumped over the lazy dog
The ^quick brown fox jumped over the lazy dog
^The quick brown fox jumped over the lazy dog
...

Mac OS X has a similar keyboard shortcut (Option – I mapped "Ctrl" to "Option" specifically so I could get this same functionality in the way I've become accustomed to).

However, "OptionArrow" brings me to the end of the current word when using the right arrow key, as illustrated here:

^The quick brown fox jumped over the lazy dog
The^ quick brown fox jumped over the lazy dog
The quick^ brown fox jumped over the lazy dog
The quick brown^ fox jumped over the lazy dog
The quick brown fox^ jumped over the lazy dog
...

And, what's worse, going the other direction doesn't bring you back to the same spot as moving forward, it brings you to the start of the last word:

The quick brown fox^ jumped over the lazy dog
The quick brown ^fox jumped over the lazy dog
The quick ^brown fox jumped over the lazy dog
The ^quick brown fox jumped over the lazy dog
^The quick brown fox jumped over the lazy dog
...

This is extremely frustrating for me, as I need to switch between Windows and Mac often, and very rarely do I want to go to the end of the current word (why would I want that, unless I'm holding "Shift" as well?). I always want to skip to the beginning of the next word.

I'm willing to go to some lengths to make the Mac version work the same way (purchase software, write a custom Applescript command tied to these keyboard shortcuts), so I'm looking for suggestions.

Are there any existing tools that will change this for me?

How would you suggest "fixing" it?

Thanks

EDIT

I was able to make a "Service" in Automator, and used the following AppleScript:

on run {input, parameters}

    tell application "System Events" to key code 124 using {option down}
    tell application "System Events" to key code 124

end run

Then I tied this Service to the "Command" keystroke using the "Keyboard" settings in System Preferences.

However, for this to work I have to take my finger off the Command key.. which makes it sorta pointless. It's also slow, and don't seem to work in the application I most need it to work in (Xcode).

Best Answer

Here's how you can get ⌃ Control+arrow keys to work like you describe. Copy the following property list into ~/Library/KeyBindings/DefaultKeyBinding.dict (you can create the directory if it doesn't already exist):

{
    "^\UF703" = ("moveWordForward:", "moveWordForward:", "moveWordBackward:");
    "^$\UF703" = ("moveWordForwardAndModifySelection:", "moveWordForwardAndModifySelection:", "moveWordBackwardAndModifySelection:");
}

This will set up ⌃ Control+arrow to navigate to the beginning of the next word (by using OS X's normal navigation three times: to the end of the current word, end of the next word, then back to the beginning of the next word). I also included a version that works with ⇧ Shift so you can select text as you go.

Caveat: this will only work in Cocoa apps, but I think the normal ⌥ Option+arrow navigation does too. Also, make sure to relaunch your apps!