GuyKhmel
GuyKhmel

Reputation: 505

Selecting every other line in VS Code with regex

I have a file where every line is duplicated (unfortunately).

My Name Is John
My Name Is John
I'm 30 years old
I'm 30 years old
New York is my home town
New York is my home town

I want to "revert" the duplication, in other words, select every other line and delete it. Is there a way to do it using regex replacement in VS Code?

(Working on a mac, so Notepad++ solutions like here are irrelevant. I know it's possible using bash, but I want to try to do it in VS Code)

Upvotes: 3

Views: 6140

Answers (1)

Amal Murali
Amal Murali

Reputation: 76656

You can achieve this using Replace-All with regex. Find:

(.*)\n\1

Replace with:

$1\n

That should do it.

Upvotes: 8

Related Questions