Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a regular expression to find the text I want (I wrapped the relevant section in custom tags), and I can do it by hand without much issue, but what I want is a way to automatically find and replace throughout the entire project.

A macro seems like an OK idea, but it would be nice to have a command (to edit and tweak). sed seems like a good bet, but I am pretty unfamiliar with it. I am not so much asking for a complete solution as I am asking for an example that does something close to what I want. I don't really know of a good way to start.

share|improve this question
Did you try Edit -> Find… -> Find in Project…? It's not a one-click solution but it supports regexes, allows you to edit patterns and see what is matched before the actual replace and keeps an history of the previous patterns for you. – romainl Mar 16 '11 at 9:35
yeah, that works. (I dismissed it before because it doesn't macro very well, but it may be the best option.) thanks. – griotspeak Mar 18 '11 at 14:58
up vote 0 down vote accepted

Use Command+F

Check the box that says Regular expression

In the Find: text field, enter the RegExp that properly captures the character set you want to replace use () to encapsulate the section of the text you want to store in the match data.

In the Replace: text field, type in the replacement regex. You can use $1 up to $9 to use the match data recorded in the 1st to the 9th set of characters captured by () in the Find text field.

This is what I use to automate boring tasks such as replacing newlines with spaces when copying a PDF to a text file

# Find

# Replace

An example with match data would be as follows

# Find

# Replace

... assuming you want to deflate those numeric addition clauses in a source code.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .