Join us today!

Notifications
Clear all

Multi-line find replace command in Notepad++

3 Posts
3 Users
4 Likes
381 Views
TwinControls
(@beckhoffsupport)
Posts: 71
Member Admin
Topic starter
 

When you need to find and replace multiple lines in Notepad++, you must select Extended as search mode on the replace menu.

replace

 

For example, to replace the lines below : 

//replaces these lines with new lines
new line 1
new line 2

//new lines
new line 1
new line 2

 

Find what: my test line 1\r\nmy test line 2

Replace with: new line 1\r\nnew line 2

 

 

This method comes in very handy when you need to modify multiple lines in an xml file with thousands of lines in it. 

In case you want to say thank you !)
We'd be very grateful if you could share this community with your colleagues and friends. You can also buy us a coffee to keep us fueled 😊 This is the best way to say thank you to this project and support your community.
twinControls - https://twincontrols.com/

 
Posted : 30/08/2022 1:05 pm
deecoop88 reacted
(@mirek-boniewicz)
Posts: 12
Active Member
 

In Notepad++ and other good editors like SublimeText or JetBrains (pycharm clion intelliJ) i recommend using regular expressions.

 Not only you can change everything you need, but search might be used as a variable (match group). So you can do everything, like swap columns in CSV, change standard of some numbers (serials with "-" between groups etc.)

This is page about regular expressions.

Regular Expression Reference: Capturing Groups and Backreferences (regular-expressions.info)

Discovering Regex in text editing is like discovering quantum physics - small interesting effect which evolved to brand new world 😉

Example:

If you have 

4-5-6 and want to achieve 654 (rearranging and concatenate digits) just type:

search : (\d)-(\d)-(\d)

replace with: \3\2\1 

I was shocked when I learned using regex. it should be taught in primary school.

If you have a problem with Regex, I will be happy to help.

 
Posted : 24/10/2022 2:28 am
rruiter and twinControls reacted
rruiter
(@rruiter)
Posts: 63
Estimable Member
 

@mirek-boniewicz +1 on learning regex. After I learned it, I discovered so many usages for it. I never imagined that I could use this skill so often :D.

My blog: https://cookncode.com/twincat
My code: https://github.com/roald87

 
Posted : 24/10/2022 7:40 am
twinControls reacted
Share: