I suggest you ...

Give option to search only in uncommented code

When searching for a string in a project's source code, I often find myself wasting time examining lines that have been commented out. it would be useful to offer an option to return only lines that are not commented out, so as not to confuse the results.

166 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    JeffJeff shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    8 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Campbell WildCampbell Wild commented  ·   ·  Flag as inappropriate

        Where is this "Find References" option? Or do you mean right-click on a variable and Find All References? Because whilst that is useful, there are still many times when you need to search for something that isn't an object, for example, a string value or a line of code.

      • Ben Voigt [Visual C++ MVP]Ben Voigt [Visual C++ MVP] commented  ·   ·  Flag as inappropriate

        Instead of a textual search, use "Find References". That will exclude commented code, remarks in comments, appearances inside quoted strings, and similarly named but unrelated items.

      • Campbell WildCampbell Wild commented  ·   ·  Flag as inappropriate

        I totally agree with this, but it's not just commented out code. Valid comments can quite easily contain the same content as a bit of code you are searching for.

        There really needs to be an option to search in comments, defaulted to off. How often do people actually need to search comments?!

      • Tim BurrisTim Burris commented  ·   ·  Flag as inappropriate

        @Boogaloo: It's obvious in the code view. Colorization does not apply to find results, so especially in the case of multi-line comments, it's not all all obvious whether the line is commented out.

      • Mark HurdMark Hurd commented  ·   ·  Flag as inappropriate

        I think this is a good idea, but it must separately allow/deny single line comments, multi-line comments, XML comments, and, importantly, #IFed out code.

      • BoogalooBoogaloo commented  ·   ·  Flag as inappropriate

        It should be pretty obvious that the code you are looking at is commented out. If not, try changing your "Comment" color to something less like your actual code color.

      Feedback and Knowledge Base