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!
@iGameRam's suggestion of KeyRemap4MacBook ended up working for me. I selected KeyRemap4MacBook because I am already using it to remap keys for me system wide. To do this I had to read the reference manual.
From the reference manual I found that there is a private.xml
file that enables me to add more remapping values to KeyRemap4MacBook. By going to the KeyRemap4MacBook pref pane, going to the "Misc & Uninstall" tab and selecting "Open private.xml" I was able to open the file.
I had to add two elements to my private.xml
. The first was:
<appdef>
<appname>SPOTIFY</appname>
<equal>com.spotify.client</equal>
</appdef>
This is because KeyRemap4MacBook does not ship with an app definition for Spotify. It does ship with many others. I need the app definition so my keyboard keybindings only apply for Spotify and are not system wide.
The second element I added was:
<item>
<name>Spotify Vim Style Nav</name>
<appendix>J and K works in Spotify</appendix>
<identifier>private.spotify.vim_style_nav</identifier>
<only>SPOTIFY</only>
<autogen>--KeyToKey-- KeyCode::J, KeyCode::CURSOR_DOWN</autogen>
<autogen>--KeyToKey-- KeyCode::K, KeyCode::CURSOR_UP</autogen>
</item>
This is the actual definition of the key bindings. The <identifier>
tag is supposed to be unique for every key mapping. The manual suggests prefixing the identifier with private.
. The <only>
tag has to match an appname defined in the private.xml
or shipped with KeyRemap4MacBook.
The <autogen>
tags are supposed to contain the mappings. The manual has many examples on what kind of mappings that can be created. The two I have map the J and K keys to the Down and Up keys respectively.
Once the file has been saved, I just needed to press the "ReloadXML" button and then my mapping appeared as an option in the menu.
After selecting it everything worked as I wanted.
Best Answer
Install and launch Karabiner. In the menubar open the menulet Karabiner -> Preferences. Then hit the tab "Misc & Uninstall" and "Open private.xml"
Paste the following lines into the opened xml file:
and save the file.
Return to the tab "Change Key", hit "ReloadXML" and enable "Swap Minus and Alt+Shift+Minus". It should be the first entry listed.
If you are left-handed you may replace _L by _R in the xml file.