tcf01
tcf01

Reputation: 1789

Place multiple cursors with the same word prefix in VS code vim plugin

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

Upvotes: 7

Views: 5123

Answers (2)

alexbhandari
alexbhandari

Reputation: 1398

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

Upvotes: 3

Hessuew
Hessuew

Reputation: 773

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.

Upvotes: 15

Related Questions