Reputation: 312
I tried looking up this questions but they were for the entire line.
My question is for example let url = "https://robohash.org/hello.png?set=set4";
here, is there any shortcut to select only the url or basically anything enclosed between "". Is it possible?
Upvotes: 11
Views: 10022
Reputation: 163
I just found a magical shortcut :)
For expand selection we can use Shift + Alt + ⇨
See Basic Editing § Shrink/expand selection for more details and examples.
Upvotes: 14
Reputation: 1194
There is actually another extension called expand-region with the ability to
expand_region
and undo_expand_region
. The default keybindings are ctrl+w and shift+ctrl+w.
I find this one to be more convenient.
It stops before and after "
and it will work for the url-fetch scenario.
What it doesn't do is to stop at a complete line (with and without indentation) which smart select
seems to do. There are probably more differences that I don't know about.
You have to press multiple times to expand further. For the example line in the original post this means 3 times. ctrl+w, ctrl+w, ctrl+w
let url = "https://robo[cursor-here]hash.org/hello.png?set=set4";
https://robohash.org/hello.png?set
https://robohash.org/hello.png?set=set4
"https://robohash.org/hello.png?set=set4"
Upvotes: 0
Reputation: 569
AFAIK this is not possible without an extension. You can download Quick and Simple Text Selection, the use ctrl+k "
shortcut.
If you're familiar with Vim, you can use the vim extension, and then click v i "
to enter visual mode, and choose everything between double quotes
For the sake of completeness, VSCode also includes a smart select
option, which has the keyboard shortcuts (The shortcut has been changed to ctrl+shift+right_arrow
and ctrl+shift+left_arrow
alt+shift+left/right_arrow
). The problem with it is it doesn't specifically select everything between double quotes, and in the case of a URL, it doesn't simply work as intended. If it's only a simple string, it would also select the double quotes in addition to the string between them
Update 04/2024:
VSCode's smart select
behavior differs depending on the language.
To summarize, smart select
is currently not a "one size fits all" solution to OP's question
Upvotes: 4
Reputation: 2001
For mac, the "expand selection" shortcut is control + shift + ▶
Click anywhere in the link and expand the selection twice, that should do it.
Upvotes: 2