How can I search in Visual Studio and get it to ignore what is commented out?

Viewed 10995

I am refactoring a C++ codebase in Visual Studio 2005. I'm about half way through this process now and I've commented out a lot of old code and replaced or moved it. Now I'm searching to see that I have to change next but the search function keeps bringing me the old commented out stuff I no longer care about. I don't really want to delete that old code yet, just in case.

Is there any way I can search all files in the solution and get results ignoring what is commented out? I don't see a way in visual studio itself, is the perhaps a plug-in that would do it?

8 Answers

My take:

yes you can use regular expressions, those tend to be too slow and thinking about them distracts from focusing on real stuff - your software.

I prefer non-obtrusive semi-inteligent methods:

Poor man's method: Find references if you happen to use intelisense on

Or even better: Visual assist and it's colored "Find all References" and "Go To" mapped to handy shortcuts. This speeds up navigation tremendously.

If you comment your old code with // you can use regular expressions while searching for something in your codebase. Something like this for example: ^[^/][^/].*your_function_name.*.

delete the commented out code, it is in source control right? there is no need to keep it in the file as well.

Related