skip to Main Content

I know in visual studio code you can select a keyword (e.g. "bob") and press Command+Shift+L to select all instances of it. But what if I currently have two different keywords selected with the alt key (e.g. "bob" and "alice"), Command+Shift+L only selects all "bob" or all "alice". How do I get all instances of both selected in this case? Is regex the only way?

2

Answers


  1. Yes regex is the way.

    • in Find dialog enable regex search: .* button
    • in Find dialog enter the regex: b(bob|alice)b
    • in Find dialog press: Alt+Enter
    Login or Signup to reply.
  2. There is an easy way to do that with an extension I wrote, Find and Transform. Make this keybinding in your keybindings.json:

    {
      "key": "alt+q",            // whatever keybinding you want
      "command": "findInCurrentFile",
      "args" : {
          // the description is optional
          "description": "This will select all matches of the selected items"
      }
    }
    

    When using the extension with no arguments, like find, replace, etc. it will automatically find all matches of any selected terms or pieces of text – it doesn’t matter how many there are.

    You don’t even need to select the whole word, a cursor in a word will select that whole word and any other matches.

    select All matches of selected text

    select all matches of words at cursors

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search