Skip to content

Instantly share code, notes, and snippets.

@mustafaturan
Last active June 30, 2025 06:13
Show Gist options
  • Save mustafaturan/dc310c6b93f5cdc7742e17e731ba8693 to your computer and use it in GitHub Desktop.
Save mustafaturan/dc310c6b93f5cdc7742e17e731ba8693 to your computer and use it in GitHub Desktop.
remove duplicate lines vscode

Preferences: Open Keyboard Shortcuts (JSON)

Add something like this:

// removes duplicate lines: find ^(.+)(?:\r?\n\1)+$ → replace $1
{
  "key": "ctrl+alt+d",
  "command": "actions.findWithArgs",
  "args": {
    "searchString": "^(.+)(?:\\r?\\n\\1)+$",
    "replaceString": "$1",
    "isRegex": true,
    "triggerReplace": true
  }
}

Reload, then hit Ctrl + Alt + D to instantly open Find with your regex/replace pre-filled.

Steps

  1. Search for ^(.+)(?:\r?\n\1)+$
  2. Replace with $1
  3. Replace all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment