I am beginning work on a large Visual Studio solution, and have come across areas that have large blocks of commented-out code. The blocks are usually more than 3 lines in length, and all start with // (probably Ctrl+K,C was used to comment these out). I would like to try to find out all the places these exist in my solution so our team can address them, and delete them if they are no longer needed (after all, we are using proper source-code control and can always go back in history to see the old code!).
So I am interested in commented out blocks of code that span more than 3 consecutive lines (and I don't want get a lot of false-positives for the XML documentation comments either). What regular expression can I use in Visual Studio's find dialog to look for these blocks? I tried the following, but it doesn't seem to work:
//[^/].*\n[:Wh]*//[^/].*\n[:Wh]*//[^/]
I'm not trying to do a find-and-replace - just find them and we'll look at them before deleting the code if it's no longer needed.
Thanks!
The other answers didn't work for me in Visual Studio 2012 (not sure if anything's changed). The following did:
(^[ \t]*//[^/].*\r?\n){3,}
Try this one:
[:Wh]//[^/].*\n[:Wh]*//[^/].*\n[:Wh]*//[^/].*\n
Works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With