Supporting Techniques - Notepad++ - Find/Replace Text

I've been using Notepad++ for several years now and it is a brilliant text editor. There are others with similar abilities, Notepad++ has worked for me so far so I've stuck with it. It is updated frequently with new features.

The styling it applies to the various files formats as mentioned in my earlier piece on using it with configuration files makes complex files far more legible.

What I really like are its enormously powerful Find and Replace tools, they quickly manage almost any task involving the manipulation of text.

Ctrl +H opens the dialog:

As well as the obvious uses of simply replacing one text strig with another, turn on Extended Search Mode and a range of expressions are available including:

  • \n -  The Line Feed control character LF
  • \r -  The Carriage Return control character CR
  • \t -  The TAB control character
  • \0 -  The NUL control character.
  • \\ -  The backSlash character.

For example, take a list of x,y,z coordinates that need to be inserted into a command file for use with a key-in or the batch processor:


xy= needs to be added to the start of each line.

open the text file containing the list in Notepad++:

Go to the View menu > Show Symbol > Show All Characters:

Press Ctrl + H:

The find string is \r\n, CR and LF respectively.

The replace string is identical with xy= added, no space needed between \r\n and xy=.

Note the logic is replace CR and LF like for like, but adding xy=.

Place the cursor at the start of line 3 as we don't want to add 'xy=' to lines 1 and 2 then click Replace All:

Obviously there is one extra 'xy=', but that's a trivial edit.

This would work for a list of 20,000 lines.

Ctrl + Z will undo the entire Find/Replace operation in one click if you go wrong, so it is easy to experiment.

In addition, Regular Expressions can be used to do more complex things, here is a useful introduction.

Here is a useful blog showing these and other techniques.