Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select current word in Visual Studio Code (VS Code)?

People also ask

How do you select the same word in VS?

Ctrl + Shift + L to select all occurrences of current selection.

How do you select the same item in VS code?

Alt+Enter --> Select all matches.


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".


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.


If you want to ctrl+w to behave the same as in Idea just go keyboard settings enter image description here

Search for Expand selection. Set new shortcut cmd+w or ctrl+w depending on your OS. enter image description here 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. enter image description here


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:

enter image description here