How to replace one line to two lines or more on a text file using the "find and replace mode"?

14,696

Solution 1

Depending on how your file's line endings are formatted (I'm going to assume Windows linebreaks since you said VB), you can switch the Search Mode to Extended and do something like this:

Find what: strLine
Replace with: line1\r\nline2

Solution 2

Its quite easy. If you look in the search mode you have an "Extended" mode. Use the special chars, like \n for newline. enter image description here

Share:
14,696

Related videos on Youtube

Diogo
Author by

Diogo

Updated on September 18, 2022

Comments

  • Diogo
    Diogo over 1 year

    Right now I'm developing a script with vbscript and I need to find one specific line(with a lot of occurrences) on a 5k lines source code and replace it to two new code lines(1 line to 2 lines replacement).

    I'm using Notepad++ but as far I could use any another editor to my development, I could someday confront with the same problem editing any kind of text file. I already tried to find a way on Notepad++, MS Word and even on Windows Notepad and didn't found any solution(all of them just replaced the search ocurrence with the first line of the replacement text).

    enter image description here

    There is some way to replace one text line to two or more lines when find an occurrence with Ctrl+F or Ctrl+H on a text editor?

  • Diogo
    Diogo about 12 years
    Thanks for the help, but it didn't actually works, notepad++ interpreted \n just as "\n", I mean, the replacement stayed with "line1\r\nline2" text.
  • KingRadical
    KingRadical about 12 years
    Did you make sure to switch the Search Mode to Extended?
  • Diogo
    Diogo about 12 years
    Wow, this really worked.... When I read the "Extended(\n, \r, \t, \x..." option I didn't really understood what it is intended to do... Thank you very much.
  • Diogo
    Diogo about 12 years
    Sorry, I didn't see you told to switch to Extended mode, I will accept yours as the main answear because you answeared the solution first. Thank you.