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?


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
| improve this answer | |
  • 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. – Diogo May 24 '12 at 13:41
  • Did you make sure to switch the Search Mode to Extended? – KingRadical May 24 '12 at 13:42
  • 1
    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. – Diogo May 24 '12 at 13:51

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

| improve this answer | |
  • 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 May 24 '12 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.