Deleting specific lines in visual studio editor

Sometimes in visual studio editor you want to delete all the lines containing a specified text.

This is possible using regular expression.

As you may know regular expression in vs editor are a little bit wierd...

Suppose you want to delete all the lines containing "System.Net Verbose" from the following source...

   1: [3636] [4472] 00000000 : 3C 3F 78 6D 6C 20 76 65-72 73 69 6F 6E 3D 22 31 : <?xml version="1 
   2: [3636] System.Net Verbose: 0 : 
   3: [3636] [4472] 00000010 : 2E 30 22 20 65 6E 63 6F-64 69 6E 67 3D 22 55 54 : .0" encoding="UT 
   4: [3636] System.Net Verbose: 0 : 
   5: [3636] [4472] 00000020 : 46 2D 38 22 20 73 74 61-6E 64 61 6C 6F 6E 65 3D : F-8" standalone= 
   6: [3636] System.Net Verbose: 0 : 
   7: [3636] [4472] 00000030 : 22 6E 6F 22 3F 3E 3C 53-4F 41 50 2D 45 4E 56 3A : "no"?><SOAP-ENV: 

 

Open the find and replace dialog (ctrl+H), select "regular expression" in the Find options.

Enter the string ".*System.Net Verbose.*\n" and click on replace all.

That's it.

".*" matches all characters.

\n matches the end of line

posted @ lunedì 18 febbraio 2008 23:38

Print
Comments have been closed on this topic.
«dicembre»
domlunmarmergiovensab
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234