{"id":227943,"date":"2019-12-12T11:22:30","date_gmt":"2019-12-12T19:22:30","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=227943"},"modified":"2019-12-12T11:22:30","modified_gmt":"2019-12-12T19:22:30","slug":"modernizing-find-in-files","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/modernizing-find-in-files\/","title":{"rendered":"Modernizing Find in Files"},"content":{"rendered":"<p>Find in Files is one of the most commonly used features in Visual Studio. It\u2019s also a feature that gets a substantial amount of feedback, and due to the age of the code, has been very costly to improve. Earlier this year, we decided to reimplement the feature from the ground up in order to realize significant performance and usability improvements.<\/p>\n<p>We\u2019ve released the new find in files experience in Visual Studio 2019 version 16.5 Preview 1 and we\u2019re looking for feedback from the community. We expect this experience to be the one our developers will use and love in the future, so we want to make sure we\u2019ve prioritized the right features. We still have more improvements coming that we\u2019re not quite ready to talk about yet, but before we deprecate the old experience, we want to make sure the new version is meeting the needs of our users.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-227945 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Overall-Picture.png\" alt=\"A screen capture of the new Find in Files dialog.\" width=\"825\" height=\"780\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Overall-Picture.png 825w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Overall-Picture-300x284.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Overall-Picture-768x726.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>The new experience is available by searching for \u201cFind in Files\u201d or \u201cReplace in Files\u201d in Visual Studio search (Ctrl+Q by default). You can also get to these commands with Ctrl+Shift+F and Ctrl+Shift+H respectively. The new experience is pictured above and should be easily recognized by the more modern look and consistent color theming.<\/p>\n<p>If you\u2019re not seeing the new version, you can search for \u201cPreview Features\u201d in Visual Studio search (Again, Ctrl+Q by default). On that page, make sure \u201cUse previous Find in Files\u201d is unchecked. Conversely, if you\u2019re having problems with the new experience, you can toggle this option to enable the old one. If you do find that you need the old Find in Files experience, we\u2019d love to hear why. Please feel free to supply any feedback you might have over in <a href=\"https:\/\/developercommunity.visualstudio.com\/idea\/851338\/modernized-find-in-files-in-visual-studio-2019-ver.html\">Developer Community<\/a>.<\/p>\n<h2>Performance<\/h2>\n<p>We took the previous implementation of Find in Files and reimplemented it completely in managed C#. This allows us to avoid unnecessary interop calls and gives us much more room for improving the experience. The memory consumption is smaller, and our performance is much faster.<\/p>\n<p>In our internal testing on directories containing 100k+ files, we saw searches that took over 4 minutes with the old implementation be done in 26 seconds. The biggest gains are in searches that use regular expressions, but searches without regular expressions generally cut the search time in half.<\/p>\n<h2>Specifying Paths<\/h2>\n<p>Using the new experience should feel comfortable for most folks since we\u2019ve gone with an experience that matches many other common find experiences. There are a few nuances that are worth calling out.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-227947 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Zoom-on-Find-Details.png\" alt=\"A screen capture of the Find in Files dialog that is cropped to only show the Look in and File types fields along with the options to include miscellaneous and external items.\" width=\"634\" height=\"227\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Zoom-on-Find-Details.png 634w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Zoom-on-Find-Details-300x107.png 300w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/><\/p>\n<p>The \u201cLook in\u201d box has a new option, \u201cCurrent Directory\u201d, which will search the folder that contains the currently open document. When searching a solution, there are checkboxes to include miscellaneous files (files that you\u2019ve opened but aren\u2019t part of the solution) as well as external items (files like \u201cwindows.h\u201d that you might reference but aren\u2019t part of the solution).<\/p>\n<p>The three dots button next to the \u201cLook in\u201d box work like any other browse option to specify a directory to look in, but if you\u2019ve already specified a directory, this button will append the new directory instead of replacing. For instance, if your \u201cLook in\u201d value was \u201c.\\Code\u201d, you could click the three buttons and navigate to a folder named \u201cShared Code\u201d. The \u201cLook in\u201d would now show \u201c.\\Code;.\\Shared Code\u201d and when the Find command is executed, it will search both of those folders.<\/p>\n<p>The File types folder now also can exclude files. Any path or file type prefixed with the \u201c!\u201d character will be excluded from the search. For instance, you can add \u201c!*\\node_modules\\*\u201d to the file types list to exclude any files in a node_modules folder.<\/p>\n<h2>Multiple Searches<\/h2>\n<p>One of the more frequent requests we\u2019ve gotten is the ability to keep the results from one search while doing other searches. This makes it easy to compare results and see them side-by-side. This feature has been in Visual Studio for a while, and the new experience still supports it.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-227944 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Keep-Results.png\" alt=\"\" width=\"1430\" height=\"386\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Keep-Results.png 1430w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Keep-Results-300x81.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Keep-Results-1024x276.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Keep-Results-768x207.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/p>\n<p>In the screenshot above, the Keep Results button has been enabled. Now, when a new search is executed, the results will be shown in a new tab. The screenshot above shows three searches that have already completed. Currently, this feature supports up to five searches. If you\u2019ve already got five search results showing, the next search will reuse the oldest search result tab.<\/p>\n<p>The Keep Results button is available for Find in Files as well as the Find All References feature.<\/p>\n<h2>Regular Expression Builder<\/h2>\n<p><img decoding=\"async\" class=\"alignnone wp-image-227946 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Regular-Expression-Builder.png\" alt=\"A screen capture of the Find in Files dialog with a regular expression being used. \" width=\"433\" height=\"288\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Regular-Expression-Builder.png 433w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/12\/Regular-Expression-Builder-300x200.png 300w\" sizes=\"(max-width: 433px) 100vw, 433px\" \/><\/p>\n<p>With Visual Studio 2019 version 16.5 preview 2, the Regular Expression builder will be available. The \u201cUse regular expressions\u201d checkbox will enable you to specify a <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/using-regular-expressions-in-visual-studio?view=vs-2019\">regular expression<\/a> as a pattern for a match. Checking this box with Visual Studio 2019 version 16.5 preview 2 (or later) will also bring up the Regular Expression builder, which is useful for creating regular expressions. Regular expressions can allow searches for strings that span multiple lines. For instance, the expression \u201c.*Hello.*\\r\\n.*World.*\u201d will match any occurrence of the string \u201cHello\u201d that has an occurrence of the string \u201cWorld\u201d anywhere on the next line.<\/p>\n<p>When the \u201cUse regular expressions\u201d checkbox is checked, the regular expression builder will appear next to the Find field. Clicking this will give some examples for building regular expressions as well as a link to the documentation.<\/p>\n<h2>What\u2019s Next<\/h2>\n<p>Now that the Find in Files experience has been reimplemented to use the newer patterns of Visual Studio, we\u2019re going to be able to provide more of the features we get asked for. We\u2019d love to hear your experiences with the new dialog. We\u2019re always watching <a href=\"https:\/\/developercommunity.visualstudio.com\/idea\/851338\/modernized-find-in-files-in-visual-studio-2019-ver.html\">Developer Community<\/a>, and we\u2019ve got a survey specifically for collecting feedback on the new experience that you can answer <a href=\"https:\/\/www.surveymonkey.com\/r\/ModernFind\">here<\/a>. We know there are features that aren\u2019t available today and your feedback is how we\u2019ll prioritize the rest of the features. If you\u2019re running into problems or you think the new dialog isn\u2019t working correctly, please send us feedback with the Give Feedback button in Visual Studio.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find in Files is one of the most commonly used features in Visual Studio, and in Visual Studio 2019 version 16.5 preview 1, we&#8217;ve given it the first round of improvements to make it faster and look more in line with the overall Visual Studio look and feel. This post will walk through the improvements and help developers get the most out of it.<\/p>\n","protected":false},"author":13892,"featured_media":227945,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[5441,5442,526,5443,287,475],"class_list":["post-227943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-find","tag-find-in-files","tag-productivity","tag-regular-expressions","tag-tips-and-tricks","tag-visual-studio-2019"],"acf":[],"blog_post_summary":"<p>Find in Files is one of the most commonly used features in Visual Studio, and in Visual Studio 2019 version 16.5 preview 1, we&#8217;ve given it the first round of improvements to make it faster and look more in line with the overall Visual Studio look and feel. This post will walk through the improvements and help developers get the most out of it.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/227943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13892"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=227943"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/227943\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/227945"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=227943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=227943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=227943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}