{"id":244885,"date":"2023-09-05T10:00:55","date_gmt":"2023-09-05T17:00:55","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=244885"},"modified":"2023-09-05T09:45:15","modified_gmt":"2023-09-05T16:45:15","slug":"keep-your-casing-with-case-preserving-find-and-replace","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/keep-your-casing-with-case-preserving-find-and-replace\/","title":{"rendered":"Keep your casing with Case-preserving Find and Replace"},"content":{"rendered":"<p><span class=\"TextRun SCXW65888556 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW65888556 BCX8\">The Visual Studio search experience is getting a new feature that allows users to find and replace text without having to worry about different casings.<\/span> <span class=\"NormalTextRun SCXW65888556 BCX8\">For example, a method parameter `<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW65888556 BCX8\">catalogItemId<\/span><span class=\"NormalTextRun SCXW65888556 BCX8\">` and object property `<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW65888556 BCX8\">CatalogItemId<\/span><span class=\"NormalTextRun SCXW65888556 BCX8\">` have the same name but different capitalization but should both be replaced by something like \u2018<\/span><span class=\"NormalTextRun SpellingErrorV2Themed SCXW65888556 BCX8\">productId<\/span><span class=\"NormalTextRun SCXW65888556 BCX8\">\u2019 with their respective casings.<\/span><\/span><span class=\"EOP SCXW65888556 BCX8\" data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-catalogItemId.png\"><img decoding=\"async\" class=\"wp-image-244894 size-full aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-catalogItemId.png\" alt=\"\" width=\"558\" height=\"384\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-catalogItemId.png 558w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-catalogItemId-300x206.png 300w\" sizes=\"(max-width: 558px) 100vw, 558px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW114685686 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW114685686 BCX8\">The feature has been requested by users who were looking for <\/span><span class=\"NormalTextRun SCXW114685686 BCX8\">an easy way<\/span><span class=\"NormalTextRun SCXW114685686 BCX8\"> to find and replace text without having to worry about different casings in various forums, including <\/span><\/span><a class=\"Hyperlink SCXW114685686 BCX8\" href=\"https:\/\/stackoverflow.com\/questions\/367052\/case-preserving-find-replace-in-visual-studio\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW114685686 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW114685686 BCX8\" data-ccp-charstyle=\"Hyperlink\">Stack Overflow<\/span><\/span><\/a><span class=\"TextRun SCXW114685686 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW114685686 BCX8\"> and Developer Community <\/span><\/span><a class=\"Hyperlink SCXW114685686 BCX8\" href=\"https:\/\/developercommunity.visualstudio.com\/t\/case-preserving-search-replace\/580810\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"TextRun Underlined SCXW114685686 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW114685686 BCX8\" data-ccp-charstyle=\"Hyperlink\">Case-Preserving Search &amp; Replace Across Multiple Files.<\/span><\/span><\/a><span class=\"TextRun SCXW114685686 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"> <span class=\"NormalTextRun SCXW114685686 BCX8\">We\u2019re<\/span><span class=\"NormalTextRun SCXW114685686 BCX8\"> excited to finally announce that <\/span><span class=\"NormalTextRun SCXW114685686 BCX8\">Case-Preserving Find and Replace is available as of 17.8 Preview 1!<\/span><\/span><\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\" target=\"_blank\">Download Visual Studio Preview<\/a><\/div><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-zoomed.gif\"><img decoding=\"async\" class=\"alignnone wp-image-244890 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-example-zoomed.gif\" alt=\"\" width=\"1882\" height=\"395\" \/><\/a><\/p>\n<p>We\u2019re committed to maintaining and improving the search experience in Visual Studio. Over the years, we\u2019ve continued to enhance and update search. You can learn more about these changes by visiting the following links:<\/p>\n<ul>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/tag\/search\/\">Search &#8211; Visual Studio Blog (microsoft.com)<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/tag\/find\/\">Find &#8211; Visual Studio Blog (microsoft.com)<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/tag\/find-in-files\/\">Find in Files &#8211; Visual Studio Blog (microsoft.com)<\/a><\/li>\n<\/ul>\n<h2>How to use it<\/h2>\n<p>When you do a Replace, you can now preserve the original casing of each match in your code. Toggle case preservation in the Replace window with `Alt+V` or by clicking on the <em>Preserve case<\/em> option.<\/p>\n<p>Quick Replace (`Ctrl+H`):<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-quick-replace-highlighted.png\"><img decoding=\"async\" class=\"alignnone wp-image-244887 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-quick-replace-highlighted.png\" alt=\"In Quick Replace dialog, Preserve case\u2019 option is represented by an &#96;AB&#96; button, located to right of \u2018Use regular expressions&#96; option.\" width=\"439\" height=\"139\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-quick-replace-highlighted.png 439w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-quick-replace-highlighted-300x95.png 300w\" sizes=\"(max-width: 439px) 100vw, 439px\" \/><\/a><\/p>\n<p>Replace in Files (`Ctrl+Shift+H`):<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-replace-in-files-highlighted.png\"><img decoding=\"async\" class=\"alignnone wp-image-244888 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-replace-in-files-highlighted.png\" alt=\"In Replace in Files window, checkbox for \u2018Preserve case\u2019 option is listed right below &#96;Use regular expressions&#96;.\" width=\"918\" height=\"427\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-replace-in-files-highlighted.png 918w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-replace-in-files-highlighted-300x140.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/09\/case-preserve-replace-replace-in-files-highlighted-768x357.png 768w\" sizes=\"(max-width: 918px) 100vw, 918px\" \/><\/a><\/p>\n<p>To get Pascal case and Camel case, your Replace string must also be in Pascal case or Camel case. Case is also preserved in text that contains hyphens or underscores.<\/p>\n<p>Examples:<\/p>\n<p>&#8211; Replacing \u201cbegin\u201d with \u201cend\u201d will turn \u201cBegin\u201d into \u201cEnd\u201d and \u201cBEGIN\u201d into \u201cEND\u201d.<\/p>\n<p>&#8211; Replacing \u201conetwothree\u201d with \u201cfourFiveSix\u201d will turn \u201conetwothree\u201d into \u201cfourfivesix\u201d, \u201coneTwoThree\u201d into \u201cfourFiveSix\u201d, and \u201cOneTwoThree\u201d into \u201cFourFiveSix\u201d.<\/p>\n<h2>Try it out and let us know what you think.<\/h2>\n<p>As you wait for it to come to the stable release, you can try out the case preserving replace experience in 17.8 Preview 1 and on. Feel free to contribute to the <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/case-preserving-search-replace\/580810\">existing ticket on Developer Community<\/a> and <a href=\"https:\/\/developercommunity.visualstudio.com\/VisualStudio\/report\">report any issues<\/a> you find on Developer Community.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\" target=\"_blank\">Download Visual Studio Preview<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Visual Studio search experience is getting a new feature that allows users to find and replace text without having to worry about different casings. For example, a method parameter `catalogItemId` and object property `CatalogItemId` have the same name but different capitalization but should both be replaced by something like \u2018productId\u2019 with their respective casings.\u00a0 [&hellip;]<\/p>\n","protected":false},"author":105708,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[5441,5442,1404],"class_list":["post-244885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-find","tag-find-in-files","tag-search"],"acf":[],"blog_post_summary":"<p>The Visual Studio search experience is getting a new feature that allows users to find and replace text without having to worry about different casings. For example, a method parameter `catalogItemId` and object property `CatalogItemId` have the same name but different capitalization but should both be replaced by something like \u2018productId\u2019 with their respective casings.\u00a0 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/244885","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\/105708"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=244885"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/244885\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=244885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=244885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=244885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}