Multiline Search and Replace

Is there an Add-in available for VS.Net 2005 that will do multiline searching and replacing In other words, what I would like to do is search for:

line 1
line 2
line 3

and replace it with:

line 1A
line 2A
line 3A
etc.

Is there a tool that does that

Thanks,

Chuck Cobb




Answer this question

Multiline Search and Replace

  • JACK SPADES

    Hi,

    Regular Expressions is what you need to accomplish your task, especially with tagged expressions.  The expression you want is

    Find what:  {.*}\n

    Replace with: \1BLAH\n

    I've written some simple tutorials on VS Regular Expressions that you can find at

    http://blogs.msdn.com/vseditor/

    The one about tagged expressions is here

    http://blogs.msdn.com/vseditor/archive/2004/07/12/181078.aspx

     (To turn on Regular Expressions, click the Use: checkbox in the find dialog, and select Regular Expressions)

    Regards,

    Fiona


  • Thomas Malbeck

    This reads mroe like a refactoring problem.

    Regardless, you can still get it done w/ what you already have. Peter Macej - of Helixoft blog - wrote a macro that extends the native regular expression search n' replace to provide multiline search n' replace. I haven't used this code myself, but the approach is promising and the blog entry appears to be well documented.

    Note that there have been numerous requests sent to Microsoft to add this feature - it's apparently not a high priority development item, which is probably a good thing.


  • Multiline Search and Replace