How to remove duplicate lines in VS Code

  1. In your desired file press cmd + f
  2. In the search bar type: ^(.*)(\n\1)+$ then press the little downwards arrow and in the replace input field type: $1

(Make sure you have the regex option selected in the find and replace popup)

3. Press the “Replace all” button

There you go! You should have all duplicates removed now!

--

--

26K+ Reads ✍🏼 Co-founder & CTO @Connect Earth. Ex-Amazon 👨‍💻 Passionate about sustainability and software👌 Views are all my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nicolas Carmont

26K+ Reads ✍🏼 Co-founder & CTO @Connect Earth. Ex-Amazon 👨‍💻 Passionate about sustainability and software👌 Views are all my own.