Skip to content

Instantly share code, notes, and snippets.

@devinschumacher
Created July 11, 2024 17:30
Show Gist options
  • Save devinschumacher/b25935c0a1b2004af1a21af5396692ed to your computer and use it in GitHub Desktop.
Save devinschumacher/b25935c0a1b2004af1a21af5396692ed to your computer and use it in GitHub Desktop.
How to Remove UNIQUE lines only (opposite of remove duplicates) in VS Code with simple `cmd+f` & REGEX
title tags
How to Remove UNIQUE lines only (opposite of remove duplicates) in VS Code with simple `cmd+f` & REGEX
vs code
productivity

How to Remove UNIQUE lines only (opposite of remove duplicates) in VS Code with simple cmd+f & REGEX

  1. Use cmd+f to open the 'Find' dialog box
  2. Click the button to 'Use Regular Expression', it looks like a .*
  3. Enter this REGEX (below) into the box, and click "Replace All" (hotkey: cmd+enter)
^(.+)$(?=\n(?:.*\n)*?\1$)

You will now be left with only the lines that were UNIQUE in the file (aka all of the items that had duplicates were removed, including the originals)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment