views:

89

answers:

3

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?

+1  A: 

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.*.

skwllsp
+2  A: 

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.

MaR
+1  A: 

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

jk
Finally this turned out to be in the only workable solution. The code was in CVS which I guess is better than nothing. I still think this type of search is something that it would be very useful for visual studio to provide out of the box. The code colouring seems to have no problem working out what is a comment and what is not so it should be relatively easy for them to provide a search which excludes comments.
RD