25

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).

1
  • Hey great question. As a fellow windows+mac user might I suggest setting your Command key to be Opt, the Opt key top be Ctrl, and the Ctrl key to Command. I found this to be the best way so far for bringing muscle memory from windows. Esp since the alt key functions much the same in a lot of apps and having it next to spacebar helps a lot. Also because Ctrl will now be in the position of the windows key and can easily be mapped to other shortcuts mimicking win+key shortcuts. Option has issues being remapped a lot of the times.
    – Brad
    Commented Jun 28, 2022 at 1:39

5 Answers 5

26

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!

8
  • Whoot! Just what I was hoping for... thank you! Let me try it then I'll mark the answer.
    – Steve
    Commented Aug 20, 2011 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
    Commented Aug 20, 2011 at 23:50
  • Whoops, yes, I meant KeyBindings! Xcode's are kind of nice because you can navigate camelCase subwords.
    – jtbandes
    Commented Aug 20, 2011 at 23:51
  • I do like the camelCase nav. Ideally, I'd like Visual Studio's behavior in Xcode... oh well.
    – Steve
    Commented Aug 21, 2011 at 0:07
  • You can, at least, customize Xcode's. There's a tab in the Preferences for changing the key bindings.
    – jtbandes
    Commented Aug 21, 2011 at 0:09
5

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.

2
  • 1
    Using KeyRemap4MacBook on OS X 10.11.x to make Control + [Arrow] work like in Windows scroll down until you find For PC Users and then check (for me, option six) "Use PC Style Control+Up/Down/Left/Right". There are other very useful options in there. Definitely up-voting this answer and on top of that it didn't cost an extra hundred of dollars!
    – John
    Commented Mar 12, 2017 at 3:15
  • This doesn't answer OP's question, but it does answer my personal question: how to remap shortcuts in MacOS? You may be able to do some thru MacOS settings, but for everything else, I recommend Karabiner Elements (formerly KeyRemap4MacBook)
    – Mike B
    Commented Jan 31, 2022 at 6:02
2

After years of the annoying OSX default mappings I switched my Command and Control keys and wanted the Control + Arrow keys to provide move-word-forward, move-word-backward functionality instead of BOL / EOL. The accepted answer worked for me except with ^ changed to @ since I now use Control instead of Command. I also mapped the lesser used BOL / EOL functions to the Option + Arrow key combinations.

{
    "@\UF702" = ("moveWordBackward:");
    "@$\UF702" = ("moveWordBackwardAndModifySelection:");
    "~\UF702" = ("moveToBeginningOfLine:");
    "~$\UF702" = ("moveToBeginningOfLineAndModifySelection:");
    "@\UF703" = ("moveWordForward:", "moveWordForward:", "moveWordBackward:");
    "@$\UF703" = ("moveWordForwardAndModifySelection:", "moveWordForwardAndModifySelection:", "moveWordBackwardAndModifySelection:");    
    "~\UF703" = ("moveToEndOfLine:");
    "~$\UF703" = ("moveToEndOfLineAndModifySelection:");
}
1

I've tried that earlier but that didn't work out for me unfortunately. Maybe I'm doing it incorrectly? I navigated to my Library folder, made a folder named "KeyBindings", and created a textEdit file named "DefaultKeyBinding" with the copied and pasted content. I also tried naming the file "DefaultKeyBinding.dict" as well. I'm on an M1 Macbook Air running BigSur.

1
  • I think indents need to be tabs, not spaces. It's possible when you copied and pasted, spaces were inserted instead of tabs.
    – Noel Yap
    Commented Sep 14, 2022 at 1:39
1

please enhance the accepted answer with the hint to disable the keybinding used for switching spaces! The DefaultKeyBinding.dict does nothing if you haven´t disabled the option in "Settings -> Keyboard -> Mission Controll -> Move left/right a space".

Checkout this for it: https://superuser.com/questions/657724/how-to-remap-ctrlarrow-keys-to-move-word-to-word-for-mac

@omwASAP does this maybe also help you?

1
  • Welcome to Ask Different. We encourage anyone to edit posts if they can help make them better. Thanks for the addition!
    – bmike
    Commented Oct 17, 2022 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .