Search & Replace with carriage return?

  • I have a file that has data copied in from another source, which did not hold any carriage returns. It looks like this:

    “value 1” “value 2” “value 3” “value 4” etc

    It contains the quotes as shown above, which is fine, as it gives me a good set of delimiters for this action, and I"m OK with leaving them in the file.

    What I WANT is this:

    “value 1”
    “value 2”
    “value 3”
    “value 4”

    Before I retired, I was a long time user of Ultraedit which could handle this just fine without any special escape characters or the like, but I’m unsure how to do it in NPP, to which I’m fairly new and haven’t done all that much with yet other than typical text stuff. Can anyone point me to a plugin or help topic or the like?



  • Hello, @ep-pack,

    Quite easy with regular expression search mode ;-)

    So given the text, below :

    "value 1" "value 2" "value 3" "value 4"

    I supposed that there is, only, one space character between the two quotation marks. Anyway, my regex S/R will work, with any standard character, between quotes !


    • Open your file in Notepad++

    • Open the Replace dialog ( Ctrl + H )

    • Type in the regex (?-s)"." , in the Find what: zone

    • Type in the regex "\r\n", in the Replace with: zone

    • Tick the Wrap around option

    • select the Regular expression search mode

    • Click, once, on the Replace All button ( or several times on the Replace button ! )

    Voilà ! You should get the following text :

    "value 1"
    "value 2"
    "value 3"
    "value 4"

    Notes :

    • First the modifier (?-s) forces the regex engine to interpret the dot ., as matching a single standard character ( different from End of line ones ! )

    • Then, the part "." matches two quotation marks, separated by any standard character

    • In replacement, we rewrite the two quotation marks, separated with \r\n, which represents a line-break ( Carriage Return + Line Feed )

    • Note that, if you use Unix files, change the replacement regex to "\n"

    Best Regards


    P.S. :

    For noob people, about regular expressions concept and syntax, begin with that article, in N++ Wiki :

    In addition, you’ll find good documentation, about the Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v5.8 ), used by Notepad++, since its 6.0 version, at the two addresses below :

    • The FIRST link explains the syntax, of regular expressions, in the SEARCH part

    • The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part

    You may, also, look for valuable information, on the sites, below :

    Be aware that, as any documentation, it may contain some errors ! Anyway, if you detected one, that’s good news : you’re improving ;-))

  • @guy038 said:


    Thank you so much! It worked perfectly! Just needed a pointer to the solution, syntax-wise. I’m reasonably familiar using regex, but not with this application.

    Again, thanks!

Log in to reply