Notepad++ – Merge all lines into one and add separator

notepadregex

So this is my situation: I have a lot of lines like this:

line1
     line2
              line3
     line4

And they all start with different spaces. What I want to do is merge all the lines in the document into one, but separate each one with some character, something like this:

line1 | line2 | line3 | line4

How can I do this?

Best Answer

No regex required in this case.

  1. Edit > Blank Operations > Trim leading Space.

  2. Replace All "\r\n" with " | " (make sure Extended Search Mode is selected):

    1

Related Question