Search code examples
replacenewlinenotepad++findinfiles

Replace several lines


In Notepad++, I would like to (find-in-files and) replace several lines, but I fail to paste several lines into the "Replace what:" text-box.

I select the lines in an opened file, press Ctrl+Shift+F, and I get the lines copied into the "Find what:" text-box. "Extended" is pre-selected.

The problem is, when I try to copy the lines from the "Find what:" text-box to the "Replace with:" text-box, only the first line is copied. Had the lines appeared with \r\n it would have solved the problem, but they don't. (I did get once the lines to appear in "Find what:" with the \r\n, but I don't know what caused it.)


Solution

  • A cumbersome workaround:

    • open a file with the multiple-lines you want to copy (but can't) into the find/replace box.
    • replace (using "Extended") all \r\n into \\r\\n.
    • you can now copy the multiple-lines as one line (with the new \r\n as text) to the search-box.