Notepad++: Replace everything before/after a character/line and merge files

Notepad++: Replace everything before/after a character/line and merge files

All characters before a certain character in Notepad ++ can be easily found and replaced with Find & Replace. For this, only the use of RegEx expressions is necessary.

As an example search term functions here e.g.


Here everything before the character “:” is searched and replaced.

To replace everything after the character “:” you can also use


can be used.

Adding characters to the beginning or end of each line

To add something to the beginning or the end of each line you can use the RegEx identifiers




can be used, where “^” stands for the beginning and “$” for the end.

Merging two files in Notepad ++

To merge two files we must first number them in each Notepad++ tab using “Alt + C” and the following settings:

Then we insert the content of the second tab below the content of the first tab and first sort the lines with “Edit->Line Operations->Sort Lines Lex. Ascending”.

Then we open the Find & Replace dialog, here we search for


which we replace with


replace. “Wrap around and Regular Expression must be enabled

If your numbering has more or less than 4 digits, the “4” in the above example must be adjusted according to the number of digits.

Now all lines are below each other and we can connect them by replacing the line break, for example:

Delete every second line break

Alternatively, we can also remove every second line break directly, by adding a new line break after


and ending it with

\1 \2


Remove every second line

Every second line can be removed by searching for


and ending it with



Leave a Reply

Your email address will not be published. Required fields are marked *