locked
Find in Files for VS2010 RRS feed

  • Question

  • I've seen some examples of stuff that at first look like what I need, but then not quite.

    And since "a picture is worth a thousands words" here's what I trying to do:

    I want to search the files of my project with a regular expression and show the results in the result window. It can't be that hard, right?

    Regards,

    Sebastián

    EDIT: I do not want to show the user this dialog. I know what to look for, so I just want to show them the result Window.


    http://bit.ly/sebagomez
    • Edited by sebastian gomez Wednesday, November 16, 2011 12:37 AM do not show fif dialog
    Wednesday, November 16, 2011 12:36 AM

Answers

  • I did, thanks.

    I found it right after I posted the question. Here's the code in case somebody finds it useful.

    DTE dte = GetService(typeof(SDTE)) as DTE;
    
    dte.Find.Action = vsFindAction.vsFindActionFindAll;
    dte.Find.Backwards = true;
    dte.Find.FilesOfType = "*.ari";
    dte.Find.FindWhat = "^" + pattern;
    dte.Find.KeepModifiedDocumentsOpen = true;
    dte.Find.MatchCase = false;
    dte.Find.MatchInHiddenText = true;
    dte.Find.MatchWholeWord = false;
    dte.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr;
    dte.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1;
    dte.Find.SearchSubfolders = true;
    dte.Find.Target = vsFindTarget.vsFindTargetCurrentDocument;
    dte.Find.Execute();
    

    Regards


    http://bit.ly/sebagomez
    Wednesday, November 16, 2011 1:35 PM

All replies

  • Maybe look into DTE.Find?

    Ryan

    Wednesday, November 16, 2011 2:26 AM
  • I did, thanks.

    I found it right after I posted the question. Here's the code in case somebody finds it useful.

    DTE dte = GetService(typeof(SDTE)) as DTE;
    
    dte.Find.Action = vsFindAction.vsFindActionFindAll;
    dte.Find.Backwards = true;
    dte.Find.FilesOfType = "*.ari";
    dte.Find.FindWhat = "^" + pattern;
    dte.Find.KeepModifiedDocumentsOpen = true;
    dte.Find.MatchCase = false;
    dte.Find.MatchInHiddenText = true;
    dte.Find.MatchWholeWord = false;
    dte.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr;
    dte.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1;
    dte.Find.SearchSubfolders = true;
    dte.Find.Target = vsFindTarget.vsFindTargetCurrentDocument;
    dte.Find.Execute();
    

    Regards


    http://bit.ly/sebagomez
    Wednesday, November 16, 2011 1:35 PM