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:
- On the first line, select the word banana with
viw
- Use the “Find Next”
cmd/ctrl + D
VSCode shortcut to select the next occurrence - Repeat Step 2 until all occurrences are selected
- Hit
esc
and then you’ll see a cursor with each selection - Hit
b
to go to the beginning of the word - Hit
cw
to change the word and type “apple”
This is what that looks like in action:
Now this might not be as quick as a regex replace, but it’s certainly one way to do it.