Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all occurrences of selected word in VSCode

Are there any trick or extension to select all instances of selected word in visual studio code, to facilitate editing or deleting those instances without search and replace, like ِAlt+F3 in sublime text

like image 731
Alaa M. Tekleh Avatar asked Oct 03 '17 07:10

Alaa M. Tekleh


People also ask

How do I select multiple occurrences in Visual Studio?

For multi-select, you can use CTRL-SHIFT-L. You can click over the word and then press key combinations(CTRL-SHIFT-L) this will select all same types of words from the file(vs-code).

How do you replace all occurrences of a string in VS code?

You can use the Find control in code or text windows, such as Output windows and Find Results windows, by selecting Edit > Find and Replace or pressing Ctrl+F.


4 Answers

Select All Occurrences of Find Match editor.action.selectHighlights.

Ctrl+Shift+L

Cmd+Shift+L or Cmd+Ctrl+G on Mac

like image 117
Alex Avatar answered Oct 21 '22 05:10

Alex


According to Key Bindings for Visual Studio Code there's:

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

and

Ctrl+F2 to select all occurrences of current word

You can view the currently active keyboard shortcuts in VS Code in the Command Palette (View -> Command Palette) or in the Keyboard Shortcuts editor (File > Preferences > Keyboard Shortcuts).

like image 42
j08691 Avatar answered Oct 21 '22 05:10

j08691


What if you want to select just a few?

No problem, first:

  1. Ctrl+F find the letters by typing them
  2. ESC to quit searching
    (you need to do this even when using Ctrl+Shift+L to select all occurences)

OR

  1. just select those letters with your mouse or keyboard (Shift+arrows)

Now that the mouse cursor is blinking on your first selection, using a few more Key Bindings (thanks for the ref j08691) you may:

  • Ctrl+D select (add) the next occurrence
  • Ctrl+K+Ctrl+D skip the current/latest occurrence and add the next occurrence
  • Ctrl+U undo the latest cursor operation
like image 90
CPHPython Avatar answered Oct 21 '22 05:10

CPHPython


on Mac:

select all matches: Command + Shift + L

but if you just want to select another match up coming next: Command + D

like image 44
Anthonyeef Avatar answered Oct 21 '22 04:10

Anthonyeef