when I select a certain word in vscode and press ctrl+shift+l
all occurrences of that word will be selected throughout the entire file, is there a way to achieve the same thing but only select the occurrences on the currently selected line?
Question posted in Visual Studio Code
View the official documentation.
View the official documentation.
3
Answers
You can select using
CTRL+SHIFT+L
in the same way. First, you select the entire line withCTRL+L
and then pressCTRL+SHIFT+L
to select all occurrences identical to the selected line. But attention to one detail,CTRL+L
also selects any blank spaces on that line.Ctrl+C
Ctrl+L
Ctrl+F
Alt+L
Ctrl+V
Alt+Enter
If you find all the commands for these shortcuts you can combine them with multi-command extension into one key binding
This is very easy with an extension I wrote, Find and Transform. Create a keybinding like:
Then just put the cursor into the word and trigger your keybinding.
And if you want to replace those matches with something just put
There are other options than within the current line, like the whole document, just the next or previous match, just the next match on the line, etc.
And if you want to replace those matches with some text just put an additional
arg
into the keybinding: