VSCode has a couple convenient ways to edit multiple pieces of text in a file at once. When you use Vim inside VSCode, how do you leverage both tools to have the same level of conveinece?

I have one answer for you! First, let’s look at an example.

Example

Let’s say you have a paragraph which mentions the word “banana” multiple times, but you want it to say “apple” instead.

Here is a sentence with banana
Another banana
Yet another banana with banana
And banana here as well.

Run these Commands

Here’s one way to achieve this:

  1. On the first line, select the word banana with viw
  2. Use the “Find Next” cmd/ctrl + D VSCode shortcut to select the next occurrence
  3. Repeat Step 2 until all occurrences are selected
  4. Hit esc and then you’ll see a cursor with each selection
  5. Hit b to go to the beginning of the word
  6. Hit cw to change the word and type “apple”

This is what that looks like in action:

gif showing how to change multiple pieces of text using vim and vscode

Now this might not be as quick as a regex replace, but it’s certainly one way to do it.