4

I need to do a find and replace, where I need to replace 2 lines at time. Does anyone know how to do this in the VS2008 IDE?

To clarify, i want to replace 2 lines with 1 line.

Many thanks

Iain Hoult
  • 3,889
  • 5
  • 25
  • 39
  • 1
    duplicate: http://stackoverflow.com/questions/2273434/multiline-find-replace-in-visual-studio – nawfal Mar 29 '12 at 17:27

3 Answers3

6

Thanks to František Žiačik for the answer to this one.

To perform a find/replace, replacing multiple lines, you need to switch on regular expressions and use a line break (\n) between your lines, also using (:b*) at the start of each line to handle any tabs or spaces tabs.

So to find:

line one
line two

you would search for ":bline one\n:bline two" (without the quotes)

Community
  • 1
  • 1
Iain Hoult
  • 3,889
  • 5
  • 25
  • 39
3

Try Multiline Search and Replace macro for Visual Studio.

Peter Macej
  • 4,831
  • 22
  • 49
0

You can activate the 'Use regular expressions' in the find dialog, and use \n to match a newline. In your case, type FirstLine\n:Zs*SecondLine.

:Zs* skips leading blanks on line 2.

For example ,\n:Zs*c matches a comma, newline, any number of blanks, a 'c'.

Mau
  • 14,234
  • 2
  • 31
  • 52