Suppose that I’m writing some text and the caret is in the middle of a word. I would like to be able to select that word without using my mouse. (Using the mouse, simply double-click on the word.)
I have found the following, but it’s kind of clunky:
- Ctrl + ←: to go to the beginning of the word
- Ctrl + Shift + →: to select the whole word
Is there a better way of doing this?
Solution:
On macOS, create a file ~/Library/KeyBindings/DefaultKeyBinding.dict
with the following content:
{ "^w" = (selectWord:);}
If the file already exists, add the second line above within its top-level braces.
Restart (quit and start again) an app to apply new key bindings.
Now you can press ^w
(Control-W
) in any native application (i.e. not Firefox, Eclipse, etc.) to have it select the current word.
You can customize the shortcut, ^
is Control, ~
Option, $
Shift, @
Command.
Some applications include menu items for this action. TextMate, for example, uses the ^w
shortcut for Edit » Select » Word by default.