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?
In the visual studio. Select View->Task list. There would be a drop down at the top of the talk list window where you can select Comments. This would show all the comments in the solution.
The new experience is available by searching for “Find in Files” or “Replace in Files” in Visual Studio search (Ctrl+Q by default). You can also get to these commands with Ctrl+Shift+F and Ctrl+Shift+H respectively.
To use Incremental Search, just press Ctrl+I and start typing. Your search term will appear in the status bar at the bottom of the screen and your search will update as you type. Press Ctrl+I again to move to the next result and Enter or Escape to end the search.
As the other provided solutions didn't work for me, I finally discovered the following solution:
^~(:b*//).*your_search_term
Short explanation:
^
from beginning of line~(
NOT the following:b*
any number of white spaces, followed by//
the comment start)
end of NOT.*
any character may appear before your_search_term
your search term :-)Obviouly this will only work for //
and ///
-style comments.
You must click "Use Regular Expressions " Button (dot and asterisk) on your find window to apply regex search
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 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