There isn't any need to download and load any external macro.
It’s working in Visual Studio 2008 with in-built macro at least. :)
Steps:
Select text you want to find.
Press Alt + F8 or open "Tools -> Macros -> Macro Explorer"
Double click Sample → Utilities → FindLine. (It will open the Find box with your selection loaded in the "Find" field. Don't worry about truncated text shown in the "Find" field. Trust me, the field has it all... The Microsoft way of showing it may be... :) )
Click on the "Quick Replace" button in the "Find And Replace" dialog box. Enter your replace with text.
And click any of three buttons as per your requirement...and it’s done. :)
Hurray... it’s working. It may not be a straightforward way to do it, but you know with Microsoft. Nothing is straightforward and easy.. :)
You can search for multiline expressions by clicking on the "Use Regular Expressions" checkbox in the "Find and Replace" dialog. Line breaks are then indicated by \n.
See how the (.*\n)+? part does the match across multiple lines, non-greedy. fooPatternToStart is some regex pattern on your start line, while barPatternToEnd is your pattern to find on another line below, possibly many lines below...
If you like to specify a multi-line replacement string as well, edit the macro code and set the replacement text as shown below.
This will allow you to "fine-tune" your replacement with just the small modifications needed.
Sub FindLine()
Dim textSelection As TextSelection
textSelection = DTE.ActiveDocument.Selection
textSelection.CharLeft(True)
DTE.ExecuteCommand("Edit.Find")
DTE.Find.FindWhat = textSelection.Text
' Also preset replacement text with current selection
DTE.Find.ReplaceWith = textSelection.Text
End Sub
The latest version (as of this posting) of Notepad++ does multi-line find/replace. With no macro support in Visual Studio any more, this is relevant now.