Home > Archive > Visual Studio > July 2004 > Search and replace multiple lines
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Search and replace multiple lines
|
|
|
| Hi
I frequently find myself wanting to search for and replace multiple lines -
where I have the same piece of code in several apsx.cs files.
Any guide as to how to do this woudl be appreciated.
David
| |
| Peter Macej 2004-07-24, 8:58 am |
| It can be done easily using regular expressions in the replace dialog.
Suppose you want to replace each occurence of two lines:
Public Property prop1() As Boolean
Get
with the following three lines:
Something
Next line
Last line
1. Go to Edit | Find and Replace | Replace in Files
2. In the Use field select Regular expressions instead of Wildcards.
3. Type the following reg. expression in Find what:
Public Property prop1\(\) As Boolean$:Wh*Get
Note, you must escape '(' by '\(', $ stands for EOL, :WH is whitespace,
* means zero or more occurences of previous expression (whitespaces in
our case). You can find a menu ">" with other characters on the right
side of the field.
4. Type in the Replace with:
Something\nNext line\nLast line
Now you can start replace.
--
Peter Macej
Helixoft - http://www.vbdocman.com
VBdocman - Automatic generator of technical documentation for VB, VB
..NET and ASP .NET code
| |
|
| Hi Peter
That sound ideal. I thought maybe regular expresions - but never really used
them.
About time I did, and now I will!
Many Thanks.
David
"Peter Macej" <peter@vbdocman***.com> wrote in message
news:u%23mXyBWcEHA.1644@tk2msftngp13.phx.gbl...
> It can be done easily using regular expressions in the replace dialog.
> Suppose you want to replace each occurence of two lines:
> Public Property prop1() As Boolean
> Get
>
> with the following three lines:
> Something
> Next line
> Last line
>
> 1. Go to Edit | Find and Replace | Replace in Files
> 2. In the Use field select Regular expressions instead of Wildcards.
> 3. Type the following reg. expression in Find what:
> Public Property prop1\(\) As Boolean$:Wh*Get
> Note, you must escape '(' by '\(', $ stands for EOL, :WH is whitespace,
> * means zero or more occurences of previous expression (whitespaces in
> our case). You can find a menu ">" with other characters on the right
> side of the field.
> 4. Type in the Replace with:
> Something\nNext line\nLast line
>
> Now you can start replace.
>
> --
> Peter Macej
> Helixoft - http://www.vbdocman.com
> VBdocman - Automatic generator of technical documentation for VB, VB
> .NET and ASP .NET code
|
|
|
|
|