1

I have a plain text file with a large number of lines with a blank line between each pair of lines. I want to remove the empty lines.

I am trying using the Replace dialog with regex, to replace '\n\n' with '\n', but the search does not recognize '\n' as the new line character.

In the Files pane of the Preferences dialog, the 'default end of line character' is set to Unix (LF) and with 'View/Show Line Endings', each line is terminated with a 'LF' icon -- or what looks to me to be an icon.

I have tried \p and \r but they don't work either.

It is a plain text file so I know there are other approaches to removing the blank lines, but I am interested in what's going on here with geany. How could I do this using the geany replace dialog?

Update I can get a match using $ as the search key but the replace all does not replace the endline character, it instead inserts before it.

  • What version of geany are you using? \n\n to \n seems to work for me (geany 1.32) when I check both the "Use regular expressions" and "Use multi-line matching" options – steeldriver Jul 8 at 23:13
  • @steeldriver Ah! I'm using 1.36, and it works just as you say. The trick was "multi-line matching". I had not enabled that. – Stephen Boston Jul 9 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.