31

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:

  1. Ctrl + : to go to the beginning of the word
  2. Ctrl + Shift + : to select the whole word

Is there a better way of doing this?

  • 1
    I think this is the simplest way to do it without a mouse. It's only 2 steps. – bwall Oct 14 '11 at 14:57
  • It depends on what program you're in. Many editors would have a keystroke for select current word. – Julian Oct 14 '11 at 15:01
  • @Julian: I'm mostly in Google Chrome, I guess. – Randomblue Oct 14 '11 at 15:29
  • 2
    You don't have to release CTRL key between step 1 & 2. So you can reduce one more key stroke, if you're not doing this yet. – Scott Rhee Jun 1 '15 at 5:09
17

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.

  • 2
    This works with Google Chrome. – Daniel Beck Oct 14 '11 at 17:53
  • Great. Thanks.. Works for me.. Ctrl + w – Syed Haider Hassan Aug 29 '15 at 6:07
  • I would only add a few remarks for this great answer: directory is KeyBindings if you have a case-sensitive file system, and you should restart apps to apply new key bindings. – rshev Apr 29 '16 at 9:28
  • 1
    @rshev That's what suggested edits are for, give it a try ;-) – Daniel Beck Apr 29 '16 at 9:39
  • What does On OS X, mean? Say I have Windows 10; What exactly do I have to do? – MJH Dec 19 '17 at 8:00
16

There is a better way. AutoHotkey.

http://www.autohotkey.com/

Or if you are in Visual Studios, Ctrl W selects the whole word.

  • 1
    How'd you configure AutoHotkey to make this work? – Daniel Beck Oct 18 '11 at 17:53
  • 7
    Visual Studio was what I was looking for, thanks. – Benjamin Mar 28 '13 at 19:55
  • 1
    +1: Excellent, for some reason I half-expected Ctrl + W to close the window I was working in in MSVC. But that's Ctrl + F4. In many other applications, Ctrl + W does just that though (closes the active window), so it seems a little dangerous to use AutoHotkey to make this shortcut work globally - maybe that's just paranoid old me? – Andon M. Coleman Sep 1 '15 at 5:41
2

This AutoHotKey script maps Ctrl-W to select the word under the cursor:

#IfWinActive ahk_class OpusApp
^W::
SendInput ^{left}+^{right}
#IfWinActive

Tested with Word 2010, should work with other versions as well.

2

In MSWord, press F8 once to enter the extended mode, twice to select the whole word, three times to select the whole sentence, four times to select paragraph and five times the entire document. Press ESC to exit the extended mode

0

The first answer was right. Do Ctrl+rightarrow then do Ctrl+Shift+leftarrow. To make this shorter, save this in a Macro. Just record those keystrokes in word and give the macro a simple keyboard shortcut like, say, Ctrl+D (D reminds me of double click).

The text of the macro in visual basic is:

Sub SelectWord()
'
' SelectWord Macro
'
'
    Selection.MoveLeft Unit:=wdWord, Count:=1
    Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
End Sub
0

Visual Studio Code

If you'd like the keybindings to match another editor: (left/right) arrows to select a whole word. In my instance: cmd+alt+shift+< or cmd+alt+shift+>, for example, do the following in VSC:

  • edit keyboard shortcuts
  • search select word
  • delete the keybindings you don't need (you might need to experiment to achieve the exact behaviour you're looking for).
  • search cursorWordStartLeftSelect
    • double click and customise: cmd+alt+shift+<
  • and search cursorWordStartRightSelect
    • double click and customise: cmd+alt+shift+>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.