Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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, "Option-Arrow" 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).

share|improve this question
add comment

migrated from serverfault.com Aug 20 '11 at 22:36

This question came from our site for professional system and network administrators.

2 Answers

up vote 11 down vote accepted

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!

share|improve this answer
    
Whoot! Just what I was hoping for... thank you! Let me try it then I'll mark the answer. –  Steve Aug 20 '11 at 23:22
    
Thanks so much! Worked like a charm. FYI "Key Bindings" vs "KeyBindings"... I used "KeyBindings" and it worked. Not sure if it makes a difference. Too bad Xcode overrides these with their own, less powerful, Key Bindings. –  Steve Aug 20 '11 at 23:50
    
Whoops, yes, I meant KeyBindings! Xcode's are kind of nice because you can navigate camelCase subwords. –  jtbandes Aug 20 '11 at 23:51
    
I do like the camelCase nav. Ideally, I'd like Visual Studio's behavior in Xcode... oh well. –  Steve Aug 21 '11 at 0:07
    
You can, at least, customize Xcode's. There's a tab in the Preferences for changing the key bindings. –  jtbandes Aug 21 '11 at 0:09
show 3 more comments

Things you might try. I have not tested these to see if they will perform the function you need.

There's a free, open-source utility for remapping key commands for Mac OS X called DoubleCommand. It's a kernel extension so it works at a very low level.

Another free program that the DoubleCommand people recommend that you check out is KeyRemap4MacBook. You need to use one or the other; they'll conflict if they are both installed on your Mac.

share|improve this answer
    
Awesome feedback, thanks. –  Steve Aug 20 '11 at 23:22
add comment

Your Answer

 
discard

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.