Paul Sasik Paul Sasik - 10 months ago 45 Question

Quick and easy way to remove "dead" (commented out) code

I'm working with an inherited code base which contains thousands of lines of commented out code. I know the previous coder meant to save all his hard work for posterity rather than simply deleting it but: I will never read it and it just gets in the way. One problem example is that when I perform text searches for certain code segments I gets dozens of "false" hits in the commented code. PITA.

Is there a quick/easy way to detect large blocks of commented out code? A clever RegEx perhaps?

I happen to be working in VB.NET at this time and comment character is a single apostrophe.


You can use a Regular Expression search. Search for


To find a single line with a comment. You'll probably want to find at least 3 lines that start with a comment:


Keep the cat away from your keyboard.