How to select current word in Visual Studio Code (VS Code)?
Solution 1:
On Mac OS: Cmd+D
On Windows & Linux: Ctrl+D
Above solved the purpose for me.
But ⌘D is defined as "editor.action.addSelectionToNextFindMatch"
, so if you press it more than once, it will try to search and select same word in the file which then can be used to do "multi word editing"
.
Solution 2:
You are looking for Shrink/Expand Selection.
Trigger it with Shift+ Alt+Left and Shift + Alt+Right
Update:
This is now called Smart select API. This feature uses semantic knowledge to intelligently expand selections for expressions, types, statements, classes, and imports.
Solution 3:
If you want to ctrl+w
to behave the same as in Idea just go keyboard settings
Search for Expand selection
. Set new shortcut cmd+w
or ctrl+w
depending on your OS.
Also re-bind other commands that use ctrl+w
to use another shortcut that you want, for example cmd+f4
You can edit keybindings.json to avoid using UI.
Solution 4:
It is Ctrl + D that works for me in latest Visual Studio Code on Windows.
Go to File -> Preferences -> Keyboard shortcuts, you will find this: