Search code examples
notepad++

Repace blank line (LF only) in Notepad++ with text


I have tried at least half a dozen suggestions for this issue but none of them are working for me.

My exact situation:

I started with a file containing text on every line (252 total lines). I need to insert a 'y' between each line so the file should look like:

text
y
text
y
text
y

etc.

Step 1) I used the following regex to insert a blank line between lines: Find: \n Replace: \n\n

This worked fine. At this point I have:

text

text

text

etc.

NOTE When I go into View\Show Symbol\Show End of Line, there are CRLF at the end of every line containing text, but only LF for the new blank lines.

At this point I want to replace the blank lines (LF only) with the letter 'y'.

NOTE 2 The 'text' lines are commands for a piece of networking equipment. This particular command then comes back with the verbose equivalent of 'Are you sure?'. I want to feed it a 'y'.

I have tried numerous suggestions from several different posts but nothing I do will replace the LF lines with a 'y' AND leave the other lines alone.

I have tried things like: ^\n$ to isolate the blank lines but even this does not work.

Several other suggestions from this and other sites are also not giving me the result I require.


Solution

  • You might do it in 1 step, searching for the end of the line and replace with a newline followed by y

    If you want to skip completely empty lines, you can assert a char to the left

    (?<=.)$
    

    enter image description here