Removing double line breaks in a text editor on Linux (Fedora)

While copy-pasting an index from a website to a spreadsheet (google sheet) recently, I found several annoying points of formatting:

  1. Each item was an html link, which could not be easily removed in bulk
  2. The items were “double spaced” using two new lines after each item.

I found the easiest way to remove this formatting was to paste the index into a text editor, which removes the links and html (I just used the default Gnome editor) and run a find and replace regular expression (regex) to remove the double lines. You can open the Find and Replace dialogue from the “hamburger” menu.

I used the \n\n to find the double new line and \n to replace it with a single new line. On Mac or Windows other expressions are used either (\r\n) or (\r). You could try \r\n?|\n if you are unsure.

The outcome was a simple text list that was easy to paste into my spreadsheet.

Hurrah!

Leave a Reply

Your email address will not be published. Required fields are marked *