Apple - Select word under cursor using a keyboard shortcut?

I don't know a single shortcut to select the word, but you can do it in two steps, by first moving the cursor to the start of the word, then select the word.

1) Move cursor to left of word:

⌥←

2) Select word to right of cursor:

⇧⌥→

Of course you could do a similar thing with moving to the right of the word with ⌥→ then selecting the word to the left of the cursor with ⇧⌥← if you prefer.


You could also create ~/Library/KeyBindings/ and save this as DefaultKeyBinding.dict:

{
    "~w" = selectWord:; // option-w
}

You have to reopen applications to apply changes. DefaultKeyBinding.dict doesn't work in Xcode or some cross-platform applications, but you could use KeyRemap4MacBook as a fallback:

<?xml version="1.0"?>
<root>
<item>
<name>Xcode</name>
<identifier>private.xcode</identifier>
<only>XCODE</only>
<autogen>__KeyToKey__ KeyCode::W, VK_OPTION | ModifierFlag::NONE, KeyCode::CURSOR_LEFT, ModifierFlag::OPTION_L, KeyCode::CURSOR_RIGHT, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L</autogen>
</item>
</root>

In the current version of Xcode, you can set up the shortcut in Preferences... ( ⌘, ) -> Key Bindings, filter "select word", then you can choose a new shorcut by typing it in the field "Key" associated

Tags:

Keyboard