5

For example I have a text

Line1

Line3

Line5

Line6

And I need to replace the blank lines with a specific text, e.g. CoolText so the result would be

Line1
CoolText
Line3
CoolText
Line5
CoolText
Line6

How to accomplish this?

1
  • I am not trying to remove the blank lines, I am trying to replace the blank lines with a specific text. Finding \r\n and replacing with CoolText does not accomplish this task, it only places CoolText at the end of each line and deletes the blank lines. Commented Jan 19, 2013 at 23:51

1 Answer 1

6

You can use the extended replacement feature in NotePad++. Search for doubled carriage return/line feed pairs (\r\n\r\n), and replace them with a carriage return/line feed pair, the replacement text, and another CR/LF pair (\r\nCoolText\r\n).

Here's the text file with the dialog set up for the replacement, before clicking "Replace All":

NPP Before Replace Image

Here are the results after clicking "Replace All":

enter image description here

1
  • In case you have 2 and more empty lines one after another, you need to press "Replace All" button a few more times =)
    – Oleg
    Commented Dec 12, 2019 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.