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.
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
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
- Use the “Find Next”
cmd/ctrl + DVSCode shortcut to select the next occurrence
- Repeat Step 2 until all occurrences are selected
escand then you’ll see a cursor with each selection
bto go to the beginning of the word
cwto 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.