How to select whole word under the cursor in Visual Studio Code?
Asked Answered
P

3

17

What hotkey or command helps to select the whole word under the cursor in VSC? (Like CTRL or ALT + D in ST3)

Posture answered 11/10, 2018 at 12:30 Comment(6)
Note that VSCode has its own tag.Stubstad
If you are on Mac, Alt+Left Arrow then Shift+Alt+Right Arrow will select the word. I'm not sure how to select a word by itself. If you go to Help -> Keyboard Shortcuts Reference, you will get a nice little helper page.Frankpledge
Could you explain what you mean with "under the cursor". I want to search the whole word only in VSCode (edit -> find). When searching "hi", I want to get "hi=123" and not "wHite" e.g..Tallula
@Timo: The question is about selecting words. "The word under the cursor" means the sequence of consecutive alphanumeric characters or underscore starting at, ending at, or including the cursor. The cursor is the blinking vertical bar that shows where you are editing. To find or search for whole words, turn on the "Ab-in-a-box" icon next to the find input (which you can get to by tabbing from the input).Rolle
I think this is a duplicate of How to select current word in Visual Studio Code (VS Code)?Hydrate
If by the whole word under the cursor you intend to select all of words like fooBar or foo_bar, then see #76082273 and a new smartSelect setting coming in vscode v1.80.Banneret
I
26

To select the word under the cursor in VSCode: ctrl + d

Inclose answered 1/2, 2019 at 15:2 Comment(3)
On Mac it's Cmd-D (because Ctrl-D deletes the char to the right)Hygro
is there ability to select by word for statements contains few words ?Capstan
Or Shift+Alt+Right Arrow (if you are at the head of the word) on windowsForeyard
C
4

Note: the definition of a "word" is different when your document edited with VSCode is a markdown one.

That is why VSCode 1.52 (Nov. 2020) proposes:

Markdown inline smart select

Expand and shrink selection in Markdown documents using the following commands:

  • Expand: kb(editor.action.smartSelect.expand)
  • Shrink: kb(editor.action.smartSelect.shrink)

Selection applies to italics, bold, inline code blocks, and links.

Smart select within a Markdown document expands from the content within an inline markdown type to include the markdown symbols. -- https://static.mcmap.net/file/mcmap/ZG-AbGLDKwftXV-pWS2nZ7-ocVI0bRywWRfQcFyQcC2jaRA/media/microsoft/vscode-docs/d603cc2985b623b6c297c757b196df6c4171e892/release-notes/images/1_52/inline-markdown-smart-select.gif

Colburn answered 5/12, 2020 at 12:12 Comment(0)
R
-3

Another simple way is to double click the mouse left button.

Retinue answered 24/6, 2021 at 5:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.