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

后端 未结 8 549
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 09:20

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\'

8条回答
  •  花落未央
    2021-02-02 09:48

    Previous answer gave a false-positive on cases where otherwise matching lines were placed on lines containing other source:

    ++i; // your_search_term gets found, don't want it found
    

    So replaced the :b* with .* and added the <> so only entire words are found, and then went after some of the older C-style comments where there's a /* on the line:

    ^~(.*//)~(.*/\*).*
    

    In my case I was hunting for all instances of new, not amenable to refactor assistance, and boatloads of false-positives. I also haven't figured out how to avoid matches in quoted strings.

提交回复
热议问题