4

In the vscode vim plugin, I use gb to select multiple words. I have four functions starting with handle but they are not exactly the same word. How can I put multi cursor for selecting them? Thanks in advance!

  handleSearchTermOnChange 
  handleActivateSearch 
  handleDeactivateSearch
  handleSearchQuery
tcf01
  • 1,699
  • 1
  • 9
  • 24

2 Answers2

4

With my understanding (in VsCodeVim) you can.

  1. v
  2. cover the desired word/prefix (in your case handle)
  3. gb as many times desired to choose all the instances you want.
  4. Then do whatever you like whit the chosen words.

Happy shortcut coding.

Hessuew
  • 583
  • 1
  • 4
  • 23
  • Just forgot the visual mode select. Thanks! – tcf01 Jul 05 '22 at 12:55
  • 1
    @tcf01 a small improvement: you can also change step 3 to `ctrl+shift+L` (which is command for "Select All Matches") if you know you want to select all occurrences. This way you can leave unnecessary `gb` clicks out and do the same thing even faster. – Hessuew Jul 06 '22 at 05:27
  • To add on the selection hit `shift+a` – Brampage Feb 05 '23 at 13:24
  • 1
    ctrl-shift-L doesn't work for me, but ctrl-d (cmd-d) does this as well. I tried to give some more detail on step 4 as well in below answer – alexbhandari May 29 '23 at 15:43
1

Expanding on this a bit more, there is multi cursor support with the below method:

  1. With cursor in desired location enter visual mode. Can do this with either CMD-D/CTRL-D (Mac/other platforms) or regular vim shortcut with the V key

enter image description here

  1. Select text with arrow/navigation keys.

enter image description here

  1. Now hit CMD-D/CTRL-D to select the next occurrence and repeat as needed to select more. Similarly gb can also be used as stated in Hessuew's answer.

enter image description here

  1. Now regular vim commands in visual mode can be used (replace, delete, etc.) or you can enter insert mode with multiple cursors by hitting: shift+i or shift+a (shown below for shift+a)

enter image description here

alexbhandari
  • 1,310
  • 12
  • 21