Wahoo, I found Notepad2. It contains the only two features I really use ALL the time in a text editor: syntax highlighting and UNIX (grep) style regular expressions search and replace.

For those who don’t know about regular expressions search and replace, it allows you to do wacky stuff like swap words, change case, and to pinpoint replacements on a source file, using bits and pieces of what you were “finding” in the “replacement”. Just don’t tell anyone you know how to use it, as it really opens up your ability to process huge input files with ease to do, well, anything.

The syntax is excruciating, but here’s some quick examples of something you might want to do (small differences exist between implementations and required escaping). Once you learn it, it’ll stay with you…

Say you had a tab delimited input file consisting of a series of datapoints , one per line, and you wanted to change it into function calls in some language. Here’s how you might do it with grep S&R:

Search: \([0-9\.]*\)\t\([0-9\.]*\)$
Replace: lineto(\1, \2);

Or how about swapping every pair of words:

Search: \([a-zA-Z]*\) \([a-zA-Z]*\)$
Replace: \2 \1

In the above examples the \( and \) group the beginning and end of the expression I will use in the replace (first one is \1, second is \2). The [ and ] are character-matching groups (i.e., match any of the things in the []‘s. The \t is a tab, * means a bunch of the previous thing, the $ is end-of-line, and the \. is used to escape out the period that could occur in a number.

It’s hard not to be an evangelist for regular expressions, because I know no other way of doing this kind of dataprocessing quickly (yes, I’m told Word has some type of regular expressions, but who uses Word these days?). Even in my current, non-technical job, I end up using a regular expression search and replace about once per couple of months, saving me an hour or more each time.