none
Controlling how Find Results window results are displayed RRS feed

  • Question

  • Hello,

    Say I want to Find all hits of ">Title=".

    The occurrences of this text are in various columns of the hit lines (e.g., one hit may be in column 10 and another may be in column 67).

    In order to be able to read down the output list very quickly, without being distracted by a jagged hit list and extraneous text surrounding the hit, is there a way to see Find results in a tidy, left-justified output window, e.g.,

    >Title='Deciding blah blah blah'

    >Title='Not structuring a negative blah blah blah'

    The hit line output in the Find Results window is jagged, like the following, which makes it difficult visually to find the hits quickly:

    'lkasd fsjkladhf jksdahfjksdahfjk sdhafjksdha fjk;sh>Title='Deciding blah blah blah'klasdjf klsajfklsdjfklsdjfkls

    'kajshdfjkshafjksdhfksh>Title='Not structuring a negative blah blah blah'klasdjfklsdajfklsdjfklsdj fkl

    Many thanks.

    Keith


    R K Howard

    Friday, January 18, 2019 12:59 PM

Answers

  • I don't know of a way to left-justify the hit output.  What I do when I need to read thru a list of results like this is to just do a Find of the hit text within the Find Results window so the cursor jumps to the start of the hit text in each line.  Hope this helps.

    Regards.

    Friday, January 18, 2019 6:05 PM

All replies

  • I don't know of a way to left-justify the hit output.  What I do when I need to read thru a list of results like this is to just do a Find of the hit text within the Find Results window so the cursor jumps to the start of the hit text in each line.  Hope this helps.

    Regards.

    Friday, January 18, 2019 6:05 PM
  • There are several formatting options: Customize how Find in Files results are displayed in the Find Results Window.


    "$0 matched text" can fulfill your requirement if you construct a search regex to include right hand text like this:

    >Title='.+'


    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    Saturday, January 19, 2019 10:58 AM
  • You can run search programmatically like this: 6. Prompt for a search string and list all matching lines from the current file.

    In this case you have complete control how to display search result. For example, changing in the example

                textSelection.SelectLine()

                outputWindowPane.OutputString("line " + textSelection.AnchorPoint.Line.ToString() + ": " + textSelection.Text)


    to

                textSelection.EndOfLine(true)

                outputWindowPane.OutputString("line " + textSelection.AnchorPoint.Line.ToString() + ": " + textSelection.Text + System.Environment.NewLine)

                textSelection.SelectLine()

    will show results in left-justified way.



    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    Saturday, January 19, 2019 11:48 AM
  • Hello. Thank you both for your answers. I need a few more days to test. I will revert. Many thanks. -Keith

    R K Howard

    Sunday, January 20, 2019 1:57 PM
  • You can run search programmatically like this: 6. Prompt for a search string and list all matching lines from the current file.

    In this case you have complete control how to display search result. For example, changing in the example

                textSelection.SelectLine()

                outputWindowPane.OutputString("line " + textSelection.AnchorPoint.Line.ToString() + ": " + textSelection.Text)


    to

                textSelection.EndOfLine(true)

                outputWindowPane.OutputString("line " + textSelection.AnchorPoint.Line.ToString() + ": " + textSelection.Text + System.Environment.NewLine)

                textSelection.SelectLine()

    will show results in left-justified way.



    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    Hello, Do I need some references other than the VCmd? as I cannot run the command. I tried the default example 'Prompt for a search string and list all matching lines from the current file (VB)' as well as with modification mentioned above.

    When I compile, I receive a success message but when I run, I get the following error:

    


    R K Howard



    Monday, January 21, 2019 3:07 PM
  • Please make sure a target code file is active before running the command. The error is probably caused by running the command from the VCmd editor.

    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    Monday, January 21, 2019 6:11 PM
  • Please make sure a target code file is active before running the command. The error is probably caused by running the command from the VCmd editor.

    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    That makes sense, once I opened up a Vb project file the command worked and the search results were justified as expected but I have some follow up questions:

    1. What if I want to search the entire solution file for a particular string? As of this moment if I have a file open and use VCmd it only searches in that file but I also want to know other occurrences of that search string outside of that file.

    2. The results are not hyperlinked? meaning that I cannot click on it to go to the line as it works with the default Find and Replace box in Visual Studio.

    Both the above are much needed feature than formatting the search results.


    R K Howard

    Tuesday, January 22, 2019 9:31 AM
  • 1. To search the entire solution you can change vsFindTarget.vsFindTargetCurrentDocument to vsFindTarget.vsFindTargetSolution. But the rest of this example code is not designed for such scenarion.

    2. To make search results clickable, change the outputWindowPane.OutputString line to:

    outputWindowPane.OutputString(textSelection.Parent.Parent.FullName + "(" + textSelection.AnchorPoint.Line.ToString() + "," + textSelection.AnchorPoint.DisplayColumn.ToString() + "): " + textSelection.Text + System.Environment.NewLine)


    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    Tuesday, January 22, 2019 4:58 PM
  • You were right, It is not designed for such scenario.

    When I applied the "vsFindTargetSolution" it doesn't display any of the search results the "Matching Lines output window" but instead opens all the project files containing the search results. also the Matching Lines output window lists irrelevant results. 

    Search results are clickable.


    R K Howard

    Wednesday, January 23, 2019 6:44 AM
  • Hi Keith,

    Thank you for your update and does your issue is solved or not?

    If Sergey's reply is helpful for your issue, please mark it as answer and that will help other community members to easier search it, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, January 29, 2019 7:54 AM
    Moderator
  • Hi Sara,

    Sergey's reply was helpful but doesn't solve my problem. As I mentioned in the reply to him.

    When i use his method to search for a string it only displays junk results in the "Matching Lines" output and opens all the search results files in new tabs. which means I cannot use the command properly.

    I am looking for a better solution.


    R K Howard

    Thursday, January 31, 2019 6:58 AM